angular/packages/core/rxjs-interop
Andrew Scott 02a539cb14 refactor(core): Synchronously emit the current signal value in toObservable (#49894)
As described in
https://github.com/angular/angular/discussions/49681#discussioncomment-5628930,
if an `Observable` created from a signal with `toObservable` is
subscribed to in a template, it will initially have `null` as the value.
Immediately after the template is done executing, effects are flushed
and this results in the `AsyncPipe` getting a new value before the
`checkNoChanges` pass, resulting in `ExpressionChanged` error.

```
template: '{{obs$ | async}}'
...
obs$ = toObservable(signal(0));
```

Instead, this commit updates the `toObservable` to synchronously emit
the initial value to the Observable stream.

Side note here: We don't exactly encourage this pattern. Instead of
using `AsyncPipe`, the template should just read signals.

PR Close #49894
2023-04-25 09:27:38 -07:00
..
src refactor(core): Synchronously emit the current signal value in toObservable (#49894) 2023-04-25 09:27:38 -07:00
test refactor(core): Synchronously emit the current signal value in toObservable (#49894) 2023-04-25 09:27:38 -07:00
BUILD.bazel build(core): introduce @angular/core/rxjs-interop entrypoint (#49154) 2023-03-30 09:44:38 -07:00
index.ts build(core): introduce @angular/core/rxjs-interop entrypoint (#49154) 2023-03-30 09:44:38 -07:00
PACKAGE.md build(core): introduce @angular/core/rxjs-interop entrypoint (#49154) 2023-03-30 09:44:38 -07:00
public_api.ts build(core): introduce @angular/core/rxjs-interop entrypoint (#49154) 2023-03-30 09:44:38 -07:00