@serenity-is/domwise / observeSignal

Function: observeSignal()

observeSignal<T>(signal, callback, opt?): EffectDisposer | undefined

Defined in: src/signal-util.ts:123

Observes a signal and calls the callback immediately upon subscription and when the signal changes.

Type Parameters

T

T

Parameters

signal

SignalLike<T>

Signal to observe

callback

ObserveSignalCallback<T>

Callback to execute immediately upon subscription and when the signal value changes.

opt?

lifecycleNode?

EventTarget

Optional node to tie the signal's lifecycle to.

useLifecycleRoot?

boolean

If true, currentLifecycleRoot() at the time of subscription will be recorded to be potentially used as the lifecycle node.

Returns

EffectDisposer | undefined