Skip to content
Jim Cowart edited this page Feb 2, 2015 · 2 revisions

machina.on

description: subscribes an event listener to be notified of the specified event.

machina.on( eventName, callback );

  • eventName - string argument name to which you are subscribing (note: The only event currently emitted by the machina namespace is the newfsm event).
  • callback - reference to the subscriber callback, or an anonymous function.

Example Usage:

// to subscribe
var callback = function(fsm) {
    // does something with the fsm
};
var listener = machina.on("newfsm", callback);

// to unsubscribe:
machina.off("newfsm", callback);
// OR
listener.off();