December 2018
Intermediate to advanced
196 pages
4h 48m
English
There’s one more vocabulary word before this chapter is over: subscription. While piping through an operator returns an observable:
| | let someNewObservable$ = anObservable$.pipe( |
| | map(x => x * 2) |
| | ); |
a call to .subscribe returns a Subscription:
| | let aSubscription = someNewObservable$.subscribe(console.log); |
Subscriptions are not a subclass of observables, so there’s no dollar sign at the end of the variable name. Rather, a subscription is used to keep track of a specific subscription to that observable. This means whenever the program no longer needs the values from that particular observable stream, it can use the subscription to unsubscribe from all future events:
| | aSubscription.unsubscribe(); |
Some operators, like ...
Read now
Unlock full access