Observable<T>.fromIterable constructor

Observable<T>.fromIterable(Iterable<T> data)

Creates an Observable that gets its data from data.

The iterable is iterated when the stream receives a listener, and stops iterating if the listener cancels the subscription.

If iterating data throws an error, the stream ends immediately with that error. No done event will be sent (iteration is not complete), but no further data events will be generated either, since iteration cannot continue.

Example

new Observable.fromIterable([1, 2]).listen(print); // prints 1, 2

Implementation

factory Observable.fromIterable(Iterable<T> data) =>
    Observable<T>((Stream<T>.fromIterable(data)));