Specific application:
In an Angular (6) component, I have a FormGroup
with a valueChanges object of type observable
that needs to be directed to an EventEmitter
. If this FormGroup
were never changing, its valueChanges
could be the EventEmitter
, but the FormGroup
changes (reassigned) in response to a changing combobox.
The FormGroup
represents an array of checkboxes.
The EventEmitter
is EventEmitter<{ [code: string]: boolean }>
.
Presently what is happening is:
this._myFormGroup.valueChanges.subscribe(value => this.myEventEmitter.emit(value));
Because the group is reassigned, and so I don't want to lose any subscriptions on the output event emitter.
EDIT: To clear up exactly what I am hoping for:
I would like a way to have as part of the public interface an @Output() myEventEmitter
that is the same instance always (thus maintains subscriptions).
With a form group that changes (note: it is dynamically generated for each change of the combobox) but can feed in its observable into myEventEmitter
without having to call emit in a subscribe which some view as a bad practice.