When I try setting a signal value from within an Observable that gets piped to async, I get the error:
Error: NG0600: Writing to signals is not allowed in a
computedor aneffectby default. UseallowSignalWritesin theCreateEffectOptionsto enable this inside effects.
But I'm not inside a computed or an effect, I'm inside an Observable. I also only get this through the async pipe; if I subscribe to the Observable and set my data in the next handler, it works as expected. Is this by design, or is it a bug?
refreshTrigger = new BehaviorSubject<void>(undefined);
refreshing = signal(false);
data = this.refreshTrigger.pipe(
tap(() => {
console.log("Refreshing");
this.refreshing.set(true);
}),
map(() => "Doing real work here"),
shareReplay(1)
);
{{refreshing() ? "Refreshing" : "Not refreshing"}} {{data | async}}
Update
It works fine when you make the observable asynchronous, as mentioned by @matthieu-riegler on GitHub.
You can workaround this issue by adding rxjs
delayoperator