ifandelse / machina.js

js ex machina - finite state machines in JavaScript
http://machina-js.org/
Other
1.93k stars 147 forks source link

handling events "once" ? #129

Closed mikepuerto closed 8 years ago

mikepuerto commented 8 years ago

As there is no built in "once" event handler, is there any recommended way to achieve this?

ifandelse commented 8 years ago

@mikepuerto you could do something along these lines:

var listener = someFsm.on("someEvent", function() {
    // do event handler-y things
    listener.off();
});
ifandelse commented 8 years ago

I'm going to close the issue, but feel free to follow up if you have more questions. I'll mark this for consideration in future features as well.