Skip to content
Irakli Gozalishvili edited this page Jan 19, 2012 · 1 revision

Push

Formally I refer to streams as "push style" if they are in the control of when elements become available to the consumers. Such streams are greedy forcing it's consumers to handle elements immediately and if consumers can't handle them they should employ buffering or some other techniques.

Pull

Formally I refer to streams as "pull style" if consumers of them are in control of when next element should be produced. Such streams are lazy they only produce elements on consumers request. That being said, there are cases where it's not as trivial to implement such streams and may require buffering. On the other hand library may provide buffering API without taxing consumers.

Pull or Push

Streamer library was created to solve non-trivial problem when writing complex programs in javascript of asynchronous nature. Goal was to define a data structure that could have express any (possibly infinite) number of elements that may become available over time (asynchronously) and build non-callback style APIs to manipulate such data. Primary focus on asynchronism and ease of expressing such data via "push style" streams influenced initial design, which on the other hand made consumption of such streams inherently hard, requiring buffering. This is subject to change in 2.0. Library will encourage lazy design, and support cases where it's not possible via buffering. This would make consumption of streams simple and easy regardless of underlying implementation, also taking advantage of laziness when possible.