What is the difference between Rx.Observable subscribe and forEach

In the ES7 spec, which RxJS 5.0 follows (but RxJS 4.0 does not), the two are NOT the same. subscribe public subscribe(observerOrNext: Observer | Function, error: Function, complete: Function): Subscription Observable.subscribe is where you will do most of your true Observable handling. It returns a subscription token, which you can use to cancel your subscription. … Read more

SwitchMap vs MergeMap in the #ngrx example

You are correct; switchMap will unsubscribe from the Observable returned by its project argument as soon as it has invoked the project function again to produce a new Observable. RxJs is incredibly powerful and dense, but its high level of abstraction can sometimes make code hard to understand. Let me debunk the marble diagrams and … Read more

what is a `Scheduler` in RxJS

Rx schedulers provide an abstraction that allows work to be scheduled to run, possibly in the future, without the calling code needing to be aware of the mechanism used to schedule the work. Whenever an Rx method needs to generate a notification, it schedules the work on a scheduler. By supplying a scheduler to the … Read more

Difference between .unsubscribe to .take(1)

Each serves a different purpose so it’s hard to compare them. In general if you take this source: const source = range(1,3); … and consume it with subscribe() followed immediately by unsubscribe(): source.subscribe( console.log, undefined, () => console.log(‘complete’) ).unsubscribe(); … then all values from source are going to be emitted even though we called unsubscribe() … Read more

When to use asObservable() in rxjs?

When to use Subject.prototype.asObservable() The purpose of this is to prevent leaking the “observer side” of the Subject out of an API. Basically to prevent a leaky abstraction when you don’t want people to be able to “next” into the resulting observable. Example (NOTE: This really isn’t how you should make a data source like … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)