We have the been using observable.create () a lot in previous lessons and so let's take a closer look how does it work.
The CREATE function:
varFoo =Rx.Observable.create (function (Observer) {Observer.next ( the); Observer.next ( -); Observer.next ( $); Observer.complete ();}) ; Foo.subscribe ((x)=>{console.log ('Next'+x);}, (Err)=>{console.log ('Err'+err);}, ()=>{console.log (' Done');},)
In deep, create () function equal to New rx.observable ():
var New rx.observable (function (Observer) { Observer.next); Observer.next (+); Observer.next ($); Observer.complete ();}) ;
And this also equal to:
function Subscribe (Observer) { Observer.next; Observer.next (+); Observer.next ($); Observer.complete ();} var New Rx.observable (subscribe);
So, if we get rid of RxJS, then we can create the Create () function like:
function Subscribe (Observer) {Observer.next ( the); Observer.next ( -); Observer.next ( $); Observer.complete ();}varObserver ={Next: (x)=>{console.log ('Next'+x);}, Error: (ERR)=>{console.log ('Err'+err);}, Complete: ()=>{console.log (' Done');}} SUBSCRIBE (Observer);
Of course, it's useful to having the observable type because then it had all those nice operators so we saw and that we AR e also seeing new operators coming next. If you paid attention and then you're going to remember so in the subscribe, we had previously three functions here as Argu ment. Instead of an object, as we had now, we had just these three functions.
Also, the observable type, it converts these three functions to an observer object. Before it calls this, it'll actually take these three functions and put labels in front of them as that, to create the Observer object. It ' s normalizing it.
[RxJS] Creation Operator:create ()