@tempots/dom
Signal class
Represents a signal that holds a value and notifies its listeners when the value changes.
Signature:
declare class Signal
Constructors
Constructor |
Modifiers |
Description |
---|---|---|
Represents a signal with a value of type T. |
Properties
Property |
Modifiers |
Type |
Description |
---|---|---|---|
|
Represents a collection of signals mapping to each key/field in the wrapped value. | ||
|
|
Returns a new Signal that emits the value at the specified key of the current value. | |
|
() => Computed |
Returns a signal that emits the count of values received so far. | |
|
(autoDisposeProp?: boolean) => Prop |
Derives a new property from the current signal. | |
|
() => void |
Disposes the signal, releasing any resources associated with it. | |
|
(a: T, b: T) => boolean | ||
|
Feeds a property into the signal and sets up disposal behavior. | ||
|
(fn: (value: T) => boolean, startValue?: T) => Computed | ||
|
|
Returns a new Computed object that applies the provided mapping function to the value of this Signal, and filters out values that are | |
|
|
Returns a new Signal that applies the given function to the value of the current Signal, and then flattens the resulting Signal. | |
|
() => T |
Gets the current value of the signal. | |
|
() => boolean |
Checks if the signal has any registered listeners. | |
|
Checks if a value is a Signal. | ||
|
() => boolean |
Checks whether the signal is disposed. | |
|
|
Returns a new Computed instance that applies the given mapping function to the value of this Signal. The mapping function is called whenever the value of this Signal changes. | |
|
|
Maps the values emitted by the signal to a new value asynchronously using the provided function. If the function throws an error, it will be caught and logged. If a recovery function is provided, it will be called with the error and its return value will be used as the mapped value. If no recovery function is provided, the error will be logged as an unhandled promise rejection. | |
|
|
Maps the values of the signal using the provided function | |
|
|
Creates a Signal that holds the result of a Promise. | |
|
(listener: (value: T) => void) => () => void |
Registers a listener function to be called whenever the value of the signal changes. The listener function will be immediately called with the current value of the signal. Returns a function that can be called to unregister the listener. | |
|
(listener: () => void) => void |
Adds a listener function to be called when the object is disposed. | |
|
|
Adds a computed value as a derivative of the signal. When the computed value is disposed, it is automatically removed from the derivatives list. Additionally, when the computed value is disposed, it sets the signal as dirty. | |
|
(fn: (value: T) => void) => Computed |
Invokes a callback function with the current value of the signal, without modifying the signal. | |
|
T |
Gets the value of the signal. |