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

machina.emit

description: emits an event on the machina namespace. While you can use this method, it's primarily used internally by machina to emit the newfsm event when an FSM is created.

machina.emit( eventName [, arg1, arg2, arg'n'...] );

  • eventName - string name of the event you are triggering
  • arg1-arg'n' - you can optionally pass n args to emit, which will be passed into each subscriber callback

Example Usage:

// no args, just the event
machina.emit("customEvent");

// with args
machina.emit("customEvent", { foo: "bar" });
machina.emit("customEvent", "oh, hai", 123, true);

NOTE: It's strongly encouraged to use a single argument for event payloads (i.e. - emit(eventName, data) instead of emit(eventName, arg1, arg2, arg3)).