Skip to content

Instantly share code, notes, and snippets.

@mindrones
Last active December 22, 2020 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindrones/2c26ae02b853db5dd2e6377d123979f3 to your computer and use it in GitHub Desktop.
Save mindrones/2c26ae02b853db5dd2e6377d123979f3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
"id": "Form",
"initial": "CheckingSelection",
"on": {
"SELECTION_CHANGED": {
"target": "CheckingSelection",
"actions": [
"clearQuery",
"setSelection",
"sendEdited",
"sendFormChanged"
]
},
"RENAME": {
"type": "internal",
"actions": "rename"
},
"DISCARDED": {
"target": "Stopped"
}
},
"states": {
"CheckingSelection": {
"entry": "computeLists",
"on": {
"": [
{
"target": "SelectionComplete",
"cond": "isSelectionComplete",
"actions": "sendSelectionComplete"
},
{
"target": "SelectionIncomplete"
}
]
}
},
"SelectionIncomplete": {
"entry": [
"clearQuery",
"clearTypings",
"sendSelectionIncomplete",
"sendEdited"
]
},
"SelectionComplete": {
"initial": "CheckingQuery",
"entry": [
"computeTypings",
"computeDefaultValues"
],
"on": {
"JSON_EDIT": {
"target": "SelectionComplete.QueryReady",
"actions": [
"setJSON"
]
},
"QUERY_CHANGED": {
"target": "SelectionComplete.CheckingQuery",
"actions": [
"setQuery",
"sendEdited",
"sendFormChanged"
]
},
"TREE_CHANGED": {
"target": "#Inactive",
"actions": "sendFormChanged"
}
},
"states": {
"Inactive": {
"id": "Inactive",
"on": {
"ACTIVATED": "CheckingQuery"
}
},
"CheckingQuery": {
"id": "CheckingQuery",
"entry": "computeRequest",
"on": {
"": [
{
"target": "QueryReady",
"cond": "isQueryReady"
},
{
"target": "QueryNotReady"
}
]
}
},
"QueryNotReady": {
"id": "QueryNotReady"
},
"QueryReady": {
"id": "QueryReady",
"initial": "CheckMatching",
"exit": "setNotReadyStatus",
"states": {
"CheckMatching": {
"on": {
"": [
{
"target": "Matching",
"cond": "isMatching"
},
{
"target": "Dirty"
}
]
}
},
"Matching": {
"id": "Matching",
"entry": "setMatchingStatus"
},
"Dirty": {
"id": "Dirty",
"initial": "Idle",
"on": {
"QUERY_EXECUTED": {
"target": "Dirty.CheckingCache"
}
},
"states": {
"Idle": {
"on": {
"": [
{
"target": "CheckingCache",
"cond": "isAutoExecute"
}
]
}
},
"CheckingCache": {
"entry": [
"computeCacheKey",
"sendCommitted"
],
"on": {
"": [
{
"target": "#Matching",
"cond": "isInCache",
"actions": [
"loadFromCache",
"setMatchingStatus"
]
},
{
"target": "Pending"
}
]
}
},
"Pending": {
"entry": "setPendingStatus",
"invoke": {
"id": "Pending",
"src": "apiRequest",
"onDone": {
"target": "#Matching",
"actions": [
"storeInCache",
"setResponse"
]
},
"onError": {
"target": "#Error"
}
}
},
"Error": {
"id": "Error",
"entry": [
"setErrorResponse",
"setErrorStatus"
]
}
}
}
}
}
}
},
"Stopped": {
"type": "final"
}
},
"context": {
"autoExecute": false,
"cached": false,
"hideDisabledAxes": true,
"hideDisabledAggs": false,
"hideDisabledDatasets": false,
"hideDisabledItems": true,
"matching": false,
"selectionComplete": false,
"showFullResponse": false,
"queryReady": false
}
}, {
"actions": {
"toggleAutoExecute": {
"type": "xstate.assign",
"assignment": {
"autoExecute": ctx => !ctx.autoExecute
}
},
"toggleCached": {
"type": "xstate.assign",
"assignment": {
"cached": ctx => !ctx.cached
}
},
"toggleHideDisabledAxes": {
"type": "xstate.assign",
"assignment": {
"hideDisabledAxes": ctx => !ctx.hideDisabledAxes
}
},
"toggleHideDisabledAggs": {
"type": "xstate.assign",
"assignment": {
"hideDisabledAggs": ctx => !ctx.hideDisabledAggs
}
},
"toggleHideDisabledDatasets": {
"type": "xstate.assign",
"assignment": {
"hideDisabledDatasets": ctx => !ctx.hideDisabledDatasets
}
},
"toggleHideDisabledItems": {
"type": "xstate.assign",
"assignment": {
"hideDisabledItems": ctx => !ctx.hideDisabledItems
}
},
"toggleShowFullResponse": {
"type": "xstate.assign",
"assignment": {
"showFullResponse": ctx => !ctx.showFullResponse
}
},
"toggleMatching": {
"type": "xstate.assign",
"assignment": {
"matching": ctx => !ctx.matching
}
},
"toggleSelectionComplete": {
"type": "xstate.assign",
"assignment": {
"selectionComplete": ctx => !ctx.selectionComplete
}
},
"toggleQueryReady": {
"type": "xstate.assign",
"assignment": {
"queryReady": ctx => !ctx.queryReady
}
}
},
"guards": {
"isAutoExecute": ctx => ctx.autoExecute,
"isInCache": ctx => ctx.cached,
"isMatching": ctx => ctx.matching,
"isSelectionComplete": ctx => ctx.selectionComplete,
"isQueryReady": ctx => ctx.queryReady
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment