kefirjs / kefir

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

Kefir.fromEvents jQuery incompatibility #159

Closed Macil closed 9 years ago

Macil commented 9 years ago

If a jquery event handler returns false, then jquery calls event.preventDefault() and event.stopPropagation(). emitter.emit returns a boolean representing whether the stream is still subscribed to the event, which means it will return false for the last event consumed, which will cause jquery to prevent the default action on the event and stop it from bubbling.

Demonstration: https://jsfiddle.net/85thdopv/1/. What should happen is that "beta" is printed for all clicks, and "alpha" is also printed on the first two clicks. Note that the second time you click on the foo button only causes "alpha" to be printed.

I think the event handler that Kefir.fromEvents registers should be changed to always return undefined. emitter.emit's return value doesn't match up with the meaning of jQuery event listener return values or with the event listener return values of any other environment that I'm familiar with.

rpominov commented 9 years ago

Thanks for the find, @AgentME! I'll probably be able to fix this later today.