class Signal
implements Dependency
Re-export
import { Signal } from "https://deno.land/x/tui@2.1.11/mod.ts";
Signal wraps value in a container.
Each time you set the value it analyzes whether it changed and propagates update over all of its dependants.
Constructors
new
Signal(value: T, options?: SignalOptions<T>)Properties
protected
$value: Toptional
dependants: Set<Dependant>optional
subscriptions: Set<Subscription<T>>value: T
optional
whenSubscriptions: Map<T, Set<Subscription<T>>>Methods
dispose(): void
- Overwrites signal's
value
getter with current value - Removes all subscriptions
- Removes itself from all dependants dependencies
- If any of the dependant doesn't have any other dependencies it gets disposed
- Clears dependants
drop(conditionValue: T, subscription: Subscription<T>): void
Unbind function from signal that has been previously set with Signal.when
propagate(cause?: Dependency | Dependant): void
- Run all linked subscriptions
- Update each dependant in
dependants
subscribe(subscription: Subscription<T>, abortSignal?: AbortSignal): void
Bind function to signal, it'll be called each time signal's value changes with current value as argument
toString(): string
unsubscribe(subscription: Subscription<T>): void
Unbind function from signal that has been previously set with Signal.subscribe
when(): void
Bind function to signal, it'll be called each time signal's value changes and is equal to {conditionValues}