Support on/off events #461

Merged
merged 2 commits into from Nov 12, 2014

Projects

None yet

3 participants

@raimohanska
Contributor

Some libs (for example, codemirror) publish events using on/off methods instead of addListener/addEventListener/bind. It's easy to add support for those in Bacon.fromEventTarget.

Shall we?

@wolfflow
Member
wolfflow commented Nov 7, 2014

Thumbs up! I would purge .on/.off mess from my marionettejs code, replacing it with new handlers)

@rpominov rpominov and 1 other commented on an outdated diff Nov 7, 2014
src/Bacon.coffee
@@ -59,8 +59,8 @@ Bacon.$.asEventStream = (eventName, selector, eventTransformer) ->
#
# Returns EventStream
Bacon.fromEventTarget = (target, eventName, eventTransformer) ->
- sub = target.addEventListener ? (target.addListener ? target.bind)
- unsub = target.removeEventListener ? (target.removeListener ? target.unbind)
+ sub = target.addEventListener ? target.addListener ? target.bind ? target.on
+ unsub = target.removeEventListener ? target.removeListener ? target.unbind ? target.off ? target.off
@rpominov
rpominov Nov 7, 2014

double target.off %)

@raimohanska
raimohanska Nov 7, 2014 Contributor

Oh, nicely spotted. Clearly a vim error :) Fixed in 94fb7e7

@raimohanska raimohanska merged commit 9d622bc into master Nov 12, 2014

1 check was pending

continuous-integration/travis-ci The Travis CI build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment