Input value within Observable.
Input Observable.
Optionalobserver: PartialObserver<TInput>Observer
Input value within Observable.
Input Observable.
Optionalnext: null | ((value: TInput) => void)Notify when a new value is emitted.
Optionalerror: null | ((error: any) => void)Notify when a new error is thrown.
Optionalcomplete: null | (() => void)Notify when the Observable is complete.
Accepts an Observable and optional
next,error,completefunctions. These functions must be in correct order. Useundefinedornullfor placeholder.Subscription will unsubscribe when unmount, you can also unsubscribe manually.
⚠ Note: To make it concurrent mode compatible, the subscription happens after the render is committed to the screen which means even the Observable emits synchronous values they will arrive after the first rendering.
Note that changes of callbacks will not trigger an emission. If you need that just create another Observable of the callback with [[useObservable]].
(From v2.0) You can access closure directly inside callback like in
useEffect.useSubscriptionwill ensure the latest callback is called.(From v2.3.4) when the Observable changes
useSubscriptionwill automatically unsubscribe the old one and resubscribe to the new one.⚠ Note: Due to the design of RxJS, once an error occurs in an observable, the observable is killed. You should prevent errors from reaching observables or
catchErrorin sub-observables. You can also make the observable as state and replace it on error.useSubscriptionwill automatically switch to the new one.