class Signal
implements Dependency
Re-export
import { Signal } from "https://deno.land/x/tui@2.0.0/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
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
subscribe(subscription: Subscription<T>): void
Bind function to signal, it'll be called each time signal's value changes with current value as argument
toString(): string