Signal

Abstract Class
A signal represents a piece of reactive state that can be observed for changes.

Signals can be observed by implementing the ISignalObserver interface and subscribing to the signal using Signal.AddObserver. StatefulWidgets may also access signals inside their build methods, which will automatically subscribe to the signal and rebuild the widget when the signal changes.

Properties

IsDisposed: bool

Static Methods

Computed<T>(computeFunc: Func<T>): ComputedSignal<T>
Creates a signal that recomputes its value whenever any of its dependencies change.
RemarksThe current value of a signal will be invalidated on Signal.NotifyDirty and only recomputed when accessed.

Parameters

computeFunc:Func<T> - A function that computes the value of the signal based on its dependencies. This function will be called whenever any of the signal's dependencies change.
Value<T>(initialValue: T, equality: bool): ValueSignal<T>
Creates a signal that holds a single value.

Parameters

initialValue:T - The initial value of the signal. Defaults to the default value of T.
equality:bool - If true, the signal will only notify observers when the value changes to a different value (as determined by Default). If false, the signal will notify observers whenever the value is set, even if it's the same as the current value.

Instance Methods

AddObserver(onChanged: Action, fireImmediately: bool): IDisposable
NotifyDirty(): void
NotifyObservers(): void
AddObserver(observer: ISignalObserver): bool
Dispose(): void
RemoveObserver(observer: ISignalObserver): bool

Inherited Members

Extension Methods

ToDiagnosticsNodeSafeDescribeIdentityShortHashToStringNullable

On this page