Setter (@shadow-js/core/extend)
The writer of a signal: it stores a value, or the result of an updater called with the previous value, and returns what it stored. (Setter of @shadow-js/core/extend)
The writer of a signal: it stores a value, or the result of an updater called with the previous
value, and returns what it stored. Function values cannot be passed directly because they would be
taken for updaters: wrap them, as in set(() => fn).
Import#
ts
import type { Setter } from "@shadow-js/core/extend";
Signature#
ts
interface Setter<T> {
/** Stores `value` (not a function) and returns it. */
<U extends T>(value: Exclude<U, AnyFunction>): U;
/** Stores what `updater` returns for the previous value, and returns it. */
<U extends T>(updater: (prev: T) => U): U;
}
Members#
| Name | Type | Description |
|---|---|---|
T |
T |