Skip to content

machina.utils.getDefaultOptions

Jim Cowart edited this page Feb 2, 2015 · 4 revisions

machina.utils.getDefaultOptions()

description: Called internally by machina as new FSMs (both BehaviorFsm and normal Fsm) are being created. The object returned provides a set of default values that are extended onto the instance in its constructor function. You can override this with your own implementation - but be aware that overriding it incorrectly will cause you finite state machines to become infinite kitten-eating machines of fail.

returns: an object containing the following properties:

  • initialState - the string name of the state in which the FSM should start. Not providing this will cause machina to throw an exception.
  • eventListeners - An object used to contain any event listeners.
  • states - An object used to contain the various states and their handlers.
  • namespace - A string value used to uniquely identify the FSM in the event loop (i.e. - it's unique in the browser, or in the node process, but not unique across all browsers/node processes). Not providing one will result in a default being assigned.
  • useSafeEmit - Boolean value that, if true, wraps the invocation of event handlers in a try/catch, so that exceptions will not halt the event emitting.
  • hierarchy - An object used internally in hierarchical scenarios, which keeps track of the event listener used to listen to child FSM events.
  • pendingDelegations - An object used internally in hierarchical scenarios, which keeps track of "tickets" assigned input that has been delegated to a child FSM.