fix(core): unregister onDestroy when observable errors in toSignal (#61596)

The observable terminates immediately when `error` is called, and no further emissions or completion notifications occur. Thus, we have to remove the listener in both the `error` and `complete` notifications.

PR Close #61596
This commit is contained in:
arturovt
2025-05-22 00:43:59 +03:00
committed by kirjs
parent 397416f804
commit f37b2f7650
@@ -168,6 +168,7 @@ export function toSignal<T, U = undefined>(
next: (value) => state.set({kind: StateKind.Value, value}),
error: (error) => {
state.set({kind: StateKind.Error, error});
destroyUnregisterFn?.();
},
complete: () => {
destroyUnregisterFn?.();