tapAll static method

FlowHandle tapAll(
  1. Cell source, {
  2. required void onPulse(
    1. Pulse pulse
    ),
  3. TapErrorHandler? onError,
})

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

  1. Each incoming pulse is passed to onPulse directly.
  2. No type checking is performed.
  3. If onPulse throws an error, the pulse is dropped.
  4. If onPulse succeeds, the pulse is passed through unchanged.
  5. 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:

Implementation

static FlowHandle tapAll(
  Cell source, {
  required void Function(Pulse pulse) onPulse,
  TapErrorHandler? onError,
}) {
  return TapAll(onPulse, onError: onError).toHandle(source: source);
}