kefirjs / kefir

A Reactive Programming library for JavaScript
https://kefirjs.github.io/kefir/
MIT License
1.87k stars 97 forks source link

How to end the stream created with asKefirStream function #11

Closed designeng closed 10 years ago

designeng commented 10 years ago

Should I unbind jquery event or stop the stream observation on context destruction? Can be a stream created with asKefirStream function unbound manually? ... or https://github.com/pozadi/kefir/blob/master/dist/addons/kefir-jquery.js#L29 does all work?

rpominov commented 10 years ago

The stream created with asKefirStream never ends. But it subscribes and unsubscribes to jQuery DOM events automatically when you subscribe / unsubscribe to stream itself (via .onValue / .offValue for example). Is that what you want, or you want to actually end the stream?

designeng commented 10 years ago

If endless stream does not produce memory leaks, I think .offValue is quite enough. Thank you!

rpominov commented 10 years ago

Yes, I think it doesn't, i.e. when you remove the last link to the stream, and if it has no subscribers, it will be garbage collected completely.