Thanks for the feedback.

Library authors are encouraged to use call as doing so does not involve patching the operator into Observable.prototype. Which means that consumers of the library cannot become dependent upon the library’s patching of the prototype.

If the reason is still unclear, you might want to have a look at the explanation given by Jay Phelps in this issue.

The call example imports map from rxjs/operator/map and if you look at its implementation:

export function map<T, R>(
this: Observable<T>,
project: (value: T, index: number) => R,
thisArg?: any
): Observable<R> {
return higherOrderMap(project, thisArg)(this);
}

You’ll see that it references this — so it must be called with a context. And that’s why call is needed; this is the observable instance to which the operator is applied.

Importing map from rxjs/operator/map does not add the operator to the prototype, so it cannot be called in the chained manner.

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store