Nicholas Jamieson
1 min readJul 17, 2019

--

The two are different. A BehaviorSubject represents a value that changes over time — rather than a series of events — and it is already an Observable. For change notifications to be emitted, someone has to call next on the BehaviorSubjet. That is, the calling code has to deal with an Observable.

The mechanism outlined in the article is for situations in which the caller is not dealing with an Observable — e.g. the caller is just setting a property or is calling a method. rxjs-observe uses a proxy so that the caller can continue setting properties or calling methods, but the consumer can deal with an Observable that emits next notifications whenever the caller sets a property or calls a method.

If you look at the implementation of rxjs-observe, you’ll see that a BehaviorSubject is used for properties of the proxied object — so that subsequent subscriptions receive the property’s current value.

--

--

Nicholas Jamieson
Nicholas Jamieson

Written by Nicholas Jamieson

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

No responses yet