Observer is an interface for a consumer of push-based notifications delivered by an Observable. It has below structure,
1 2 3 4 5 6 | interface Observer<T> { closed?: boolean; next: (value: T) => void; error: (err: any) => void; complete: () => void; } |
A handler that implements the Observer interface for receiving observable notifications will be passed as a parameter for observable as below,
1 | myObservable.subscribe(myObserver); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.