-
Notifications
You must be signed in to change notification settings - Fork 147
machina.emit
Jim Cowart edited this page Feb 2, 2015
·
1 revision
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.
-
eventName
- string name of the event you are triggering -
arg1-arg'n'
- you can optionally pass n args toemit
, 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 ofemit(eventName, arg1, arg2, arg3)
).