eve icon indicating copy to clipboard operation
eve copied to clipboard

Allow unbind for eve.once

Open trokster opened this issue 10 years ago • 0 comments

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 ?

trokster avatar May 26 '14 02:05 trokster