Effect<Value>.streamTask constructor

Effect<Value>.streamTask(
  1. Stream<Value> stream(), {
  2. Value onDone()?,
  3. Value onError(
    1. Object error,
    2. StackTrace stackTrace
    )?,
  4. bool cancelOnError = true,
})

Lazily constructs and subscribes to a stream returned by stream each time the effect runs. Useful when each invocation requires a new stream subscription.

Example:

final socketEffect = Effect.streamTask(() => socket.connect());

Implementation

factory Effect.streamTask(
  Stream<Value> Function() stream, {
  Value Function()? onDone,
  Value Function(Object error, StackTrace stackTrace)? onError,
  bool cancelOnError = true,
}) =>
    Effect.stream(
      stream: stream(),
      onDone: onDone,
      onError: onError,
      cancelOnError: cancelOnError,
    );