steveklabnik / frappuccino

Functional Reactive Programming in Ruby.
https://github.com/steveklabnik/frappuccino
MIT License
354 stars 33 forks source link

Adds events and has_event?(event) method to Stream #4

Closed avgerin0s closed 11 years ago

avgerin0s commented 11 years ago

events Returns an array with all the events happened to current stream (@ values)

has_event?(event) Returns true if the given event has happened in the current stream, else false.

avgerin0s commented 11 years ago

Just thought it'd be nice to have these. :)

latentflip commented 11 years ago

It's a bigger thought, but I'd question whether events should be stored as arrays internally. If you're creating a lot of streams you don't really want them all to be stored longer than they're needed or you're just going to be accumulating memory like crazy. The nice thing about bacon is that streams are lightweight - creating a stream has ~0 overhead unless it has subscribers, and even then it shouldn't be significant.

steveklabnik commented 11 years ago

Yes, they should not be arrays, it's just a temporary thing.

Thanks @eavgerinos , but I think that this isn't needed for now, since that will change anyway.