steveklabnik/frappuccino — pull request #5 by seadowg (2013-04-23 04:41:25+00:00)
Title: Switch to push based implementation

This switches the MVP code to use a very basic push based implementation rather than an array one. Array implementations of FRP events allow for arbitrary access to the past but require large quantities of memory and generally don't match up to the requirements of an infinite stream.

One caveat of using a push based implementation is that the following would happen:

stream = Frappuccino::Stream.new(button)
button.push
counter = stream.map {|event| event == :pushed ? 1 : 0 }.inject(0) {|sum, n| sum + n }
counter.to_i # => 0

This means that you have to declare the event processing you want upfront if you care about the whole stream.

I've also switched the Map class to extend Stream (which I'm guessing would have been the idea eventually anyway).