javascript - Kefir.js - How to stream events from a callback function? -


the mousetrap.js library lets bind callback function keys so:

mousetrap.bind('space', function, 'keydown');

what's best way attach stream without using bus of doom? should use emitter or pool?

i'm trying arrow keys hooked in fiddle: jsfiddle.net/vzafq25w

you can use general wrapper stream

var leftkeys = kefir.stream(function(emitter){     mousetrap.bind('left', function(e) {         emitter.emit(e);         console.log(e);     });     return function(){         // unbind     }; }); 

http://jsfiddle.net/be9200kh/1/


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -