Maxim, the main reason for passing a PartialObserver is that’s all subscribe requires. subscribe has a few overloads:

subscribe(): Subscription;
subscribe(observer: PartialObserver<T>): Subscription;
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;

And I wanted to use the one that accepted just the one argument — the PartialObserver — as that would require only a single binding property.

The basic gist of it is that subscribe can be passed an observer object — that has the option of implementing next, error and complete methods — or it can be passed separate, optional next, error and complete handlers.

Interestingly, the PartialObserver interface is now somewhat redundant, as TypeScript 2.1 introduced the concept of mapped types — see the Mapped Types section in the documentation — and the Partial type, which could be used like this:

subscribe(observer: Partial<Observer<T>>): Subscription;

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