Subjects

We are used to using Observables in a certain way. We construct them from something and we start listening to values that they emit. There is usually very little we can do to affect what is being emitted after the point of creation. Sure, we can change it and filter it, but it is next to impossible to add more to our Observable unless we merge it with another stream. Let's have a look at when we are really in control of what is being emitted when it comes to Observables, using the create() operator:

let stream$ = Rx.Observable.create(observer => {  observer.next(1);  observer.next(2);});stream$.subscribe(data => console.log(data));

We see the Observable acting as a wrapper around the thing that really emits our values, the Observer. ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.