module@warp-drive/alien-signals/primitives
The reactive primitives behind @warp-drive/alien-signals: a small signals graph built on the push-pull algorithm from alien-signals.
Most apps only need the install entry point. Import from this module when you are building a framework integration that needs to observe WarpDrive's signals, the way @warp-drive/react does for its ReactiveContext:
ts
import { Watcher, createSignal, consumeSignal, notifySignal } from '@warp-drive/alien-signals/primitives';The graph implements only what WarpDrive's SignalHooks need, not the TC39 Signals API:
- a SignalNode holds no value. It is a "side signal" that tells consumers the value it guards has changed, so every notifySignal counts as a change.
- a MemoNode caches the result of a function, including a thrown error, until a signal or memo it read changes.
- a Watcher is told, once, when anything it watches may have changed.
A memo that nothing subscribes to (no watcher, and no other memo that reads it) releases its links to the signals it read in a microtask after it is read, so a long-lived signal never keeps a short-lived memo, or the object that owns it, alive. Its next read recomputes it.