CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 10:43:03 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"c08fec350535746a03777c633c1605f2"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=afky08fM%2FFRMjZzRy2tu5RwrBygBO0NexEH6o9Ufxbc8Cuxfv75TdoSHL6wX%2FSZTE99DX2bEsVeDJYUV5YpGCl0OBrUTCpE25mynvGYMBYZLQsZmDUt%2BE1DES0GLO%2FeO%2BFNG%2FTGy9VO8J%2FCII5zFD4mlHeJZ8whD5BhG2HtxXp2HP6wkcXnGl4jg8Q04lfegGzYiqFeXts8gA%2FmPNWqpYA7TUE%2BGQn0lkBZaUck5A%2FwtFTT4ayPZ28BhC80ekaN%2Bf0ccbUEs4a9nk6i8QUogZA%3D%3D--%2BORX%2BkohJE%2B4LElg--fy1KZNeduITO2SohKSc0yw%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.61734488.1753267382; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 10:43:02 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 10:43:02 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: EE1A:394F4C:98FA5A:B8B5B1:6880BCB6
machina.fsm.constructor · ifandelse/machina.js Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 146
machina.fsm.constructor
Jim Cowart edited this page Feb 2, 2015
·
2 revisions
When you are creating a new FSM, the constructor function takes one argument: an options object providing the FSM instance its states, handlers and other properties/behavior which it needs to function.
Fsm instances will contain any properties returned from machina.utils.getDefaultOptions and getDefaultClientMeta.
The values on the options
argument can include/override any of the members provided by getDefaultOptions
and getDefaultClientMeta
- along with any other property or methods you provide. The most common instance members you will utilize are as follows:
Member | Description |
---|---|
initialState |
A string value indicating the initial state in which the FSM should exist. Defaults to uninitialized. |
eventListeners |
An object which holds event subscribers for events emitted from the FSM. It is an object that has a key for any event emitted, and the value of the key is an array of subscriber callbacks. Normally, subscribers get added by calling fsmInstance.on("eventName", callback), but providing this argument allows you to set multiple subscribers up in advance as part of creating the FSM. |
states |
An object where each top-level (own) property is a 'state', and each state property is an object containing the input handlers the FSM should utilize while in that state. Input handlers can be functions, a string value that matches another state name, or one of the special handlers (_onEnter, _onExit or the * catch-All handler). Please note that not including a states object will render your FSM useless (unless it's being used a base for more constructor extensions). |
namespace |
A string value used as a namespace for the FSM, should it be (for example) wired into a message bus. |
initialize |
A function that is executed once the instance of the FSM has been created. This gives you a chance to perform any initialization concerns on the FSM before machina itself triggers the newfsm event and before the FSM transitions into the initialState. |
One of many possible examples of new-ing up an FSM:
var fsm = new machina.Fsm( {
namespace : "connectivity",
initialState : "offline",
states : {
probing : {
_onEnter : function () {
var self = this;
if ( !self.wiredUp ) {
useStethoscope( self, stethoscope );
self.wiredUp = true;
}
stethoscope.checkHeartbeat();
},
heartbeat : "online",
"no-heartbeat" : "disconnected",
"go.offline" : "offline",
"*" : function () {
this.deferUntilTransition();
}
},
online : {
"window.offline" : "probing",
"appCache.error" : "probing",
"request.timeout" : "probing",
"go.offline" : "offline"
},
disconnected : {
"window.online" : "probing",
"appCache.downloading" : "probing",
"go.online" : "probing",
"go.offline" : "offline"
},
offline : {
"go.online" : "probing"
}
}
} );
You can’t perform that action at this time.