tapAll static method
Tap every pulse, including wrong types.
tapAll is similar to tap but the callback receives the full Pulse object, not just the payload.
When to use
Use tapAll when you need to perform side effects on every pulse, including those that don't match the expected type.
- Logging: Logging all pulses including errors.
- Debugging: Debugging pulse flow including type mismatches.
- Monitoring: Monitoring all pulses for metrics.
- Auditing: Auditing all pulses including invalid ones.
- Tracing: Tracing pulse flow through the system.
How it works
- Each incoming pulse is passed to
onPulsedirectly. - No type checking is performed.
- If
onPulsethrows an error, the pulse is dropped. - If
onPulsesucceeds, the pulse is passed through unchanged. - The pulse gets the step
'TapAll'for provenance.
Parameters:
source: The Source Cell. The cell providing the input values.onPulse: Side Effect Callback. Called with each pulse. If it throws, the pulse is dropped.onError: Error Handler. Optional callback for handling errors.
Returns:
A FlowHandle that can be used to observe the tapped values.
Example
final input = Cell.ingress<Object>();
final handle = Flow.tapAll(
input.cell,
onPulse: (pulse) => print('Pulse: ${pulse.payload}'),
);
input.emit(42); // Logs typed pulse
input.emit('hello'); // Logs typed pulse
See Also:
- tap: For typed side effects.
- tapWithIndex: For indexed side effects.
Implementation
static FlowHandle tapAll(
Cell source, {
required void Function(Pulse pulse) onPulse,
TapErrorHandler? onError,
}) {
return TapAll(onPulse, onError: onError).toHandle(source: source);
}