Reputation: 181
data = [{'info':'success'},{'info':'fail'}];
public getResults(page: Page,data:any[]): Observable<PagedData<CorporateEmployee>> {
return Observable.of(data).map(data => this.getPagedData(page,data));
}
In the above code what is the purpose of the Observable.of
operator?
Upvotes: 4
Views: 1271
Reputation: 68665
It wraps the array object into the Observable
stream for later Observable
processing. Your function returns an Observable
, the map
function is the Observable function (also array has this), and if you want to work with Observable stream, you need to convert your array into the Observable stream and use its functions.
Upvotes: 6