repeat<T> static method

Stream<T> repeat<T>(
  1. Stream<T> streamFactory(
    1. int repeatIndex
    ), [
  2. int? count
])

Creates a Stream that will recreate and re-listen to the source Stream the specified number of times until the Stream terminates successfully.

If count is not specified, it repeats indefinitely.

Example

RepeatStream((int repeatCount) =>
  Stream.value('repeat index: $repeatCount'), 3)
    .listen((i) => print(i)); // Prints 'repeat index: 0, repeat index: 1, repeat index: 2'

Implementation

static Stream<T> repeat<T>(Stream<T> Function(int repeatIndex) streamFactory,
        [int? count]) =>
    RepeatStream<T>(streamFactory, count);