batch<P> static method

Pulse batch<P>(
  1. Iterable<Pulse<P>> pulses, {
  2. PulseEphemeralPolicy? policy,
  3. PulseContext? context,
  4. String? type,
  5. Cell? source,
  6. String? step,
  7. int? priority,
  8. void onComplete(
    1. Pulse pulse
    )?,
  9. void onError(
    1. Pulse pulse,
    2. Object error, {
    3. StackTrace? stackTrace,
    })?,
  10. void onProgress(
    1. Pulse pulse,
    2. Cell cell, {
    3. String? message,
    })?,
})

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);