Skip to content

Commit

Permalink
docs: added note about toSignal (angular#54996)
Browse files Browse the repository at this point in the history
PR Close angular#54996
  • Loading branch information
ApplY3D authored and ilirbeqirii committed Apr 6, 2024
1 parent 00ecf3a commit 6d0a439
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions adev/src/content/guide/signals/rxjs-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Like the `async` pipe, `toSignal` subscribes to the Observable immediately, whic

IMPORTANT: `toSignal` creates a subscription. You should avoid calling it repeatedly for the same Observable, and instead reuse the signal it returns.

### Injection context

`toSignal` by default needs to run in an [injection context](guide/di/dependency-injection-context), such as during construction of a component or service. If an injection context is not available, you can manually specify the `Injector` to use instead.

### Initial values

Observables may not produce a value synchronously on subscription, but signals always require a current value. There are several ways to deal with this "initial" value of `toSignal` signals.
Expand Down
4 changes: 4 additions & 0 deletions aio/content/guide/rxjs-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class Ticker {
Like the `async` pipe, `toSignal` subscribes to the Observable immediately, which may trigger side effects. The subscription created by
`toSignal` automatically unsubscribes from the given Observable upon destruction of the component in which `toSignal` is called.

### Injection context

`toSignal` by default needs to run in an [injection context](/guide/dependency-injection-context), such as during construction of a component or service. If an injection context is not available, an `Injector` can instead be explicitly specified.

### Initial values

Observables may not produce a value synchronously on subscription, but signals always require a current value. There are several ways to deal with this "initial" value of `toSignal` signals.
Expand Down

0 comments on commit 6d0a439

Please sign in to comment.