Skip to content

Instantly share code, notes, and snippets.

@mindrones
Last active August 14, 2020 16:12
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/9aae5aa5cea4ab0fb7ff211edfc507d1 to your computer and use it in GitHub Desktop.
Save mindrones/9aae5aa5cea4ab0fb7ff211edfc507d1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
"id": "TestingBuilder",
"type": "parallel",
"context": {
"autoExecute": false,
"cached": false,
"hideDisabledAxes": true,
"hideDisabledAggs": false,
"hideDisabledDatasets": false,
"hideDisabledItems": true,
"matching": false,
"selectionComplete": false,
"showFullResponse": false,
"queryReady": false
},
"states": {
"GuardsConfig": {
"initial": "Idle",
"states": {
"Idle": {
"on": {
"SELECTION_COMPLETE_TOGGLED": {
"target": "Idle",
"actions": "toggleSelectionComplete"
},
"QUERY_READY_TOGGLED": {
"target": "Idle",
"actions": "toggleQueryReady"
},
"MATCHING_TOGGLED": {
"target": "Idle",
"actions": "toggleMatching"
},
"CACHED_TOGGLED": {
"target": "Idle",
"actions": "toggleCached"
}
}
}
}
},
"Route": {
"id": "Route",
"initial": "Loading",
"on": {
"ROUTE_CHANGED": {
"target": "Route.Navigating"
}
},
"states": {
"Loading": {
"on": {
"READY": {
"target": "Interactive",
"actions": [
"parseParams"
]
}
}
},
"Navigating": {
"on": {
"NAVIGATED": {
"target": "Interactive",
"actions": [
"parseParams"
]
}
}
},
"Interactive": {
"type": "parallel",
"states": {
"FormConfig": {
"initial": "Idle",
"states": {
"Idle": {
"on": {
"AUTO_EXEC_TOGGLED": {
"target": "Idle",
"actions": [
"toggleAutoExecute"
]
},
"HIDE_DISABLED_AXES_TOGGLED": {
"target": "Idle",
"actions": [
"toggleHideDisabledAxes"
]
},
"HIDE_DISABLED_AGGS_TOGGLED": {
"target": "Idle",
"actions": [
"toggleHideDisabledAggs"
]
},
"HIDE_DISABLED_DSETS_TOGGLED": {
"target": "Idle",
"actions": [
"toggleHideDisabledDataset"
]
},
"HIDE_DISABLED_FIELDS_TOGGLED": {
"target": "Idle",
"actions": [
"toggleHideDisabledFields"
]
},
"SHOW_FULL_RESPONSE_TOGGLED": {
"target": "Idle",
"actions": [
"toggleShowFullResponse"
]
},
"REQUEST_TAB_SELECTED": {
"target": "Idle",
"actions": [
"showTab"
]
}
}
}
}
},
"Docs": {
"initial": "Idle",
"states": {
"Idle": {
"on": {
"FIELD_DOC_SHOWN": {
"target": "Idle"
},
"FIELD_DOC_DEFAULT": {
"target": "Idle"
},
"AGG_DOC_SHOWN": {
"target": "Idle"
},
"AGG_DOC_DEFAULT": {
"target": "Idle"
},
}
},
}
},
"Form": {
"initial": "CheckingSelection",
"on": {
"SELECTION_CHANGED": {
"target": "Form.CheckingSelection",
"actions": [
"computeLists",
"setURL"
]
},
"SELECTION_RESET": {
"target": "Form.SelectionIncomplete",
"actions": [
"deleteNestedForms",
"setURL"
]
}
},
"states": {
"CheckingSelection": {
"on": {
"": [
{
"target": "SelectionComplete",
"cond": "isSelectionComplete",
"actions": [
"prepareForm",
"spawnNestedForm"
]
},
{
"target": "SelectionIncomplete"
}
]
}
},
"SelectionIncomplete": {},
"SelectionComplete": {
"initial": "CheckingQuery",
"on": {
"QUERY_CHANGED": {
"target": "SelectionComplete.CheckingQuery",
"actions": [
"computeRequest",
"setURL"
]
}
},
"states": {
"CheckingQuery": {
"id": "CheckingQuery",
"on": {
"": [
{
"target": "QueryReady",
"cond": "isQueryReady"
},
{
"target": "QueryNotReady"
}
]
}
},
"QueryNotReady": {
"id": "QueryNotReady"
},
"QueryReady": {
"id": "QueryReady",
"initial": "CheckMatching",
"states": {
"CheckMatching": {
"on": {
"": [
{
"target": "Matching",
"cond": "isMatching"
},
{
"target": "Dirty"
}
]
}
},
"Matching": {
"id": "Matching",
"onEntry": [
"pushHistory"
]
},
"Dirty": {
"id": "Dirty",
"initial": "Idle",
"on": {
"QUERY_EXECUTED": {
"target": "Dirty.CheckingCache"
}
},
"states": {
"Idle": {
"on": {
"": [
{
"target": "CheckingCache",
"cond": "isAutoExecute"
}
]
}
},
"CheckingCache": {
"onEntry": [
"searchInCache"
],
"on": {
"": [
{
"target": "#Matching",
"cond": "isInCache"
},
{
"target": "Pending"
}
]
}
},
"Pending": {
"invoke": {
"id": "Pending",
"src": "apiRequest",
"onDone": {
"target": "#Matching",
"actions": [
"storeInCache"
]
},
"onError": {
"target": "#Error"
}
}
},
"Error": {
"id": "Error"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}, {
"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