Why does this not work? This works calling data from the api. But if I want to update the data, all the signals do not do anything. I thought simply sending a new emission from the observable will let all the signals react. What am I not understanding.
pageData$ = this.pageDataSubject.pipe(
tap((data:any) =>{
console.log(data)
}),
switchMap((data:any) => {
if (data === null || data === undefined || data === '') {
return this.apiData$; // get data from api
} else {
return of(data); // update data if any changes made by clicks etc
}
})
) as any;
pageData = toSignal(this.pageData$) as any; // convert the above to signal
checkPageChanges = effect((data) => { // this fires when api resolves.
console.log(this.pageData());
});
Then when I click something
update(){
this.pageDataSubject.next(newData);
}
All the console logs in the rxjs works but not the signals.