bespokejs / bespoke

DIY Presentation Micro-Framework
http://markdalgleish.com/projects/bespoke.js/
MIT License
4.69k stars 442 forks source link

Add an off method #60

Closed mojavelinux closed 9 years ago

mojavelinux commented 9 years ago

Add an off method as a complement to the on method. I've come across situations in my plugins when I want to listen for deck events only at certain times. It would be nice if I could unregister an event handler. jQuery has an off method for this very purpose. I think Bespoke.js needs the same.

If I understand the code correctly, it seems that if you invoke the function that is returned from the on method, it unregisters the event.

deck.on('activate', activate)();

However, this is a very bizarre API, IMO. I'd much rather have an explicit off method to call.