Protocol & interop
Low-level callbag constants and helpers exported from the main package for advanced use, testing, and custom operators.
Callbag type constants
import { START, DATA, END, STATE } from 'callbag-recharge';| Constant | Value | Meaning |
|---|---|---|
START | 0 | Handshake; payload is talkback |
DATA | 1 | Value emissions only (no sentinels) |
END | 2 | Completion or error (error payload) |
STATE | 3 | Control channel (DIRTY, RESOLVED, …) |
Control signals
import { DIRTY, RESOLVED } from 'callbag-recharge';DIRTY— “My value is about to change.” Phase 1 of the two-phase push.RESOLVED— “I was dirty but the value did not change.” Downstream can skip recomputation.
Unknown STATE payloads are forwarded for forward compatibility.
Connection batching
When wiring many subscribers at once, producer factories can be deferred so all sinks attach before any source starts:
import { beginDeferredStart, endDeferredStart } from 'callbag-recharge';
beginDeferredStart();
try {
// subscribe multiple stores / effects...
} finally {
endDeferredStart();
}deferStart(fn)— If insidebeginDeferredStart…endDeferredStart, queuesfn; otherwise runs immediately. Used internally when asource()subscription triggers upstream start.
deferEmission
Queues a callback to run when the current batch drain runs (same mechanism as batch()). Primarily for internal primitives; library authors extending the graph may use it with care.
teardown(store)
Force-completes a store-compatible node and propagates END through downstream subscribers.
import { state, teardown } from 'callbag-recharge';
const s = state(0);
// ... subscriptions ...
teardown(s);
// Node is terminal; typical stores stop accepting new writes after complete.Works with nodes that expose complete() (producer, state, operator) or internal _handleEnd (derived).
NodeStatus
String lifecycle status on nodes (e.g. for Inspector.inspect):
DISCONNECTED | DIRTY | SETTLED | RESOLVED | COMPLETED | ERRORED
See also
- batch — defer DATA while preserving DIRTY ordering
- operator — must forward STATE and emit RESOLVED when filtering
- Architecture — full protocol narrative