Thanks.

Unless the situation has changed recently, the recommendation is to not treat an EventEmitter like an observable.

So the main reason for passing an Observer is to avoid the mismatch between event callbacks and observable sources. In my own code, I’d pass an Observer. However, if I were writing a library, I’d be more inclined to expose an event. Callers could then use their own Subject and call its next method in the event handler, passing $event as the value — that is, it would be up to the callers to deal with the mismatch.

In situations where the service requires more than one field, I’d use the this.form.valueChanges for the form and would omit the map operation that's used in the article's source — so all of the form’s fields are forwarded to the observer.

For multiple partial forms, I’d use the same mechanism. I’d use combineLatest to combine the information received by the observers passed to the subforms and I’d use map to select the relevant data that’s to be passed to subforms via their observable inputs.

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store