dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.57k forks source link

Stream.fromIterable: document lazy iteration #18962

Open DartBot opened 10 years ago

DartBot commented 10 years ago

This issue was originally filed by @seaneagan


Stream.fromIterable waits for the event from the previous iterable element to be emitted, before further advancing the iterator. This should be documented.

cbracken commented 10 years ago

Added Area-Documentation, Docs-API, Library-Async, Triaged labels.

lrhn commented 10 years ago

What would the alternative be? Reading all the elements of the iterable first and then starting to emit events?

kevmoo commented 10 years ago

Changed the title to: "Stream.fromIterable: document lazy iteration".

kevmoo commented 10 years ago

Removed Area-Documentation label. Added Area-Library, Type-Documentation labels.

DartBot commented 10 years ago

This comment was originally written by @seaneagan


Yes, that would be the alternative. The implemented behavior is obviously better, but since lazy iteration is not documented, I assumed the simplest impl that came to mind, which was eager iteration. The lazy (async) iteration could lead to ConcurrentModificationErrors, so I would almost be tempted to warn about that.

Also, the laziness of Iterable.map/where/etc. is explicitly documented.