batch<P> static method
Pulse
batch<P>(
- Iterable<
Pulse< pulses, {P> > - PulseEphemeralPolicy? policy,
- PulseContext? context,
- String? type,
- Cell? source,
- String? step,
- int? priority,
- void onComplete(
- Pulse pulse
- void onError(
- Pulse pulse,
- Object error, {
- StackTrace? stackTrace,
- void onProgress(})?,
Creates a collective pulse from an iterable of individual pulses.
When to use
- Atomic Bundling: Use this when you have several pulses that should travel together as a single atomic unit — for example, when one logical operation updates multiple cells, and you want all updates to propagate together.
- One logical operation updates multiple cells.
- You want atomic propagation across several signals.
- Reducing dispatch overhead by batching.
- Applying common metadata to a group of pulses.
- Coordinating multiple state changes that depend on each other.
How it works
The individual pulses are bundled into a CollectivePulse. The collective moves through the graph as a single entity, but each sub‑pulse retains its own identity, trace, and callbacks.
Non‑obvious: this is a flat bundle, not a chain
Unlike evolve, which creates a causal chain, batch creates a flat collection. There's no parent‑child relationship between the pulses — they're just grouped together for atomic propagation.
Parameters:
pulses: The pulses to bundle.policy: Optional lifecycle policy for the bundle.context: Optional provenance context for the bundle.type: Optional semantic tag.source: Optional originating cell.step: Optional trace step.priority: Optional urgency (overrides individual priorities).onComplete: Called when all sub‑pulses complete.onError: Called if any sub‑pulse fails.onProgress: Called during processing.
Example
final pulse1 = Pulse('Update user');
final pulse2 = Pulse('Update account');
final batch = Pulse.batch([pulse1, pulse2]);
Implementation
static Pulse batch<P>(
Iterable<Pulse<P>> pulses, {
PulseEphemeralPolicy? policy,
PulseContext? context,
String? type,
Cell? source,
String? step,
int? priority,
void Function(Pulse pulse)? onComplete,
void Function(Pulse pulse, Object error, {StackTrace? stackTrace})? onError,
void Function(Pulse pulse, Cell cell, {String? message})? onProgress,
}) =>
_CollectivePulse<P>(pulses);