DelayWhenStreamTransformer<T> class Null safety

Delays the emission of items from the source Stream by a given time span determined by the emissions of another Stream.

Interactive marble diagram

Example

Stream.fromIterable([1, 2, 3])
  .transform(DelayWhenStreamTransformer(
      (i) => Rx.timer(null, Duration(seconds: i))))
  .listen(print); // [after 1s] prints 1 [after 1s] prints 2 [after 1s] prints 3

Stream.fromIterable([1, 2, 3])
  .transform(
     DelayWhenStreamTransformer(
       (i) => Rx.timer(null, Duration(seconds: i)),
       listenDelay: Rx.timer(null, Duration(seconds: 2)),
     ),
  )
  .listen(print); // [after 3s] prints 1 [after 1s] prints 2 [after 1s] prints 3
Inheritance

Constructors

DelayWhenStreamTransformer(Stream<void> itemDelaySelector(T value), {Stream<void>? listenDelay})
Constructs a StreamTransformer which delays the emission of items from the source Stream by a given time span determined by the emissions of another Stream.

Properties

hashCode int
The hash code for this object.
read-onlyinherited
itemDelaySelector Stream<void> Function(T value)
A function used to determine delay time span for each data event.
final
listenDelay Stream<void>?
When listenDelay emits its first data or done event, the source Stream is listen to.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

bind(Stream<T> stream) Stream<T>
Transforms the provided stream.
override
cast<RS, RT>() StreamTransformer<RS, RT>
Provides a StreamTransformer<RS, RT> view of this stream transformer.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited