Observable<T>.periodic constructor

  1. Duration period,
  2. [T computation(
    1. int computationCount

Creates an Observable that repeatedly emits events at period intervals.

The event values are computed by invoking computation. The argument to this callback is an integer that starts with 0 and is incremented for every event.

If computation is omitted the event values will all be null.


 new Observable.periodic(new Duration(seconds: 1), (i) => i).take(3)
   .listen(print); // prints 0, 1, 2


factory Observable.periodic(Duration period,
        [T computation(int computationCount)]) =>
    Observable<T>((Stream<T>.periodic(period, computation)));