I have a page component, a list component and a detail component (parent to child hierarchy: page->list->detail) and I'm trying to get an observable in the detail component up to the page component through component sharing.
I've tried doing this by putting the observable in an EventEmitter and sending it upward, however, it doesn't seem to be working. It could be one of two things: I'm incorrectly sending the observable up, or I'm correctly sending the observable up and I'm incorrectly extracting it from the EventEmitter. The code looks something like this.
Detail component:
@Output() outputHumidityWarning$ = new EventEmitter<Observable<boolean>>();
...
ngOnInit() {
this.outputHumidityWarning$.emit(this.humidityWarning$);
}
Where humidityWarning$ is of type Observable
List component template:
<app-detail (outputHumidityWarning$)="inputHumidityWarning($event)"</app-detail>
List component:
private humidityWarning = new Replaysubject<boolean>(1);
...
ngOnInit() {
this.humiditywarning.subscribe(all => console.log(all));
}
...
inputHumidityWarning = function (humidityWarning) {
this.humidityWarning = humidityWarning;
}
I've also tried:
inputHumidityWarning = function (humidityWarning) {
this.humidityWarning.next(humidityWarning);
}
...
inputHumidityWarning = function (humidityWarning) {
this.humidityWarning.next(of(humidityWarning));
}
No errors but I won't get anything on the console. When I console.log this.humidityWarning after setting it, I'll get an AnonymousSubject. This is why I tried wrapping it an of(). When I console.log(humidityWarning) I'll get an EventEmitter