eve
eve copied to clipboard
Allow unbind for eve.once
Couldn't find a clean way to do it so my approach is to pass in a third variable ( array or pointer ) then modify eve.once to assign f2 to that variable, so i can unsub with eve.off("evt", f2).
eve.once = function (name, f, unbinder) { var f2 = function () { eve.unbind(name, f2); return f.apply(this, arguments); }; if(unbinder) unbinder.push(f2); return eve.on(name, f2); };
It's absolutely ugly but does the job for now. Does anyone have a cleaner way to implement ?