What is the purpose of Observable.of operator in RXJS library?

Viewed 1257
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?

1 Answers

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.

Related