module@warp-drive/alien-signals/primitives
Function createSignal() sincev5.10.0
ts
function createSignal(obj: object, key: string | symbol): SignalNode;Defined in: primitives.ts:169
Creates a SignalNode for key on obj. This is the createSignal hook of the SignalHooks that the install entry point configures.
Parameters
obj
object
the object the signal belongs to, kept for debugging in development builds
key
string | symbol
the key the signal is for, kept for debugging in development builds
Returns
a new signal
Example
ts
import { consumeSignal, createSignal, notifySignal } from '@warp-drive/alien-signals/primitives';
const signal = createSignal(user, 'name');
consumeSignal(signal); // inside a memo, the memo now depends on the signal
notifySignal(signal); // the memo recomputes on its next read