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.