Replies: 1 comment
-
As discussed / identified in #4122 (hat tip to @e-oz), here is a solution that seems to be working well for me: BEFORE: pipe(
switchMap((id) => {
return this.otherService.get$(id).pipe(...);
}),
...
} AFTER: pipe(
combineLatestWith(toObservable(this.otherService.getSignal(id))),
switchMap(([id, signalValue]) => {
return …;
}),
...
} Note these are not fully equivalent and may exhibit subtle differences based on how you use them (for more on this it's worth digging into how the inner observable within a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Thinking of the classic
switchMap
(or other flattening operator) approach to switch to another observable and keep a live "channel" open, e.g.:What would the equivalent approach and best practice be to switch to an observable from a signal (i.e. react to changes to that signal, e.g. in an
rxMethod
within asignalStore
method)?An initial idea:
… i.e. using the
toObservable
helper from@angular/core/rxjs-interop
.EDIT: the above currently doesn't work (in a SignalStore) as it throws an injection error (it needs to be run within an injection context).
But is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions