I am puzzled by the issue in my code found at this link. I am using widgetNameForm$ to send data to a child component. However, even though switchMap should switch to the valueChanges stream and emit values when typing in an input field, it is not working as expected. Previously, I had a different code structure with nested subscriptions, but I prefer a more reactive approach as shown on StackBlitz below:
this.widgetName$.subscribe(val => {
this.widgetNameForm = this.formBuilder.group({
name: [val, {validators: Validators.required}]
});
this.widgetNameForm.valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe(val => console.log('it emits value on typing', val));
})