batch method
Aggregates multiple signals into a single, flat CollectivePulse.
This is the fluent equivalent of calling Pulse.batch. It is the preferred
way to bundle signals when you have a dynamic collection of pulses or when
you want a flat structure rather than the nested hierarchy created by the
binary + operator.
When to use
- Atomic Batching: Sending multiple related updates (e.g., from a list of changed items) through the graph in a single propagation step.
- Flattening: Ensuring that even if the source list contains composite pulses, the result is a single-level collection.
Comparison: + vs .batch()
| Feature | p1 + p2 + p3 |
[p1, p2, p3].batch() |
|---|---|---|
| Logic | Binary Composition (Nested) | Flat Aggregation |
| Structure | [[p1, p2], p3] |
[p1, p2, p3] |
| Length | 2 | 3 |
Example
final updates = [Pulse('A'), Pulse('B'), Pulse('C')];
final collective = updates.batch();
print(collective.length); // 3
Implementation
Pulse batch() => Pulse.batch(this);