Skip to content

Instantly share code, notes, and snippets.

@carloslfu
Last active September 1, 2020 23:42
Show Gist options
  • Save carloslfu/3c1a53cf80ab2d72547710731d8f1788 to your computer and use it in GitHub Desktop.
Save carloslfu/3c1a53cf80ab2d72547710731d8f1788 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
"id": "(machine)",
"key": "(machine)",
"context": {
"callId": -1,
"callType": "room",
"isDesktop": false
},
"type": "compound",
"initial": "initial",
"history": false,
"states": {
"initial": {
"id": "(machine).initial",
"key": "initial",
"type": "atomic",
"history": false,
"states": {},
"on": {
"RECEIVE_CALL": [
{
"target": [
"#(machine).ringing"
],
"actions": [],
"event": "RECEIVE_CALL",
"source": "#(machine).initial",
"internal": false,
"eventType": "RECEIVE_CALL"
}
],
"RECEIVE_ROOM_CALL": [
{
"target": [
"#(machine).ringing"
],
"actions": [],
"event": "RECEIVE_ROOM_CALL",
"source": "#(machine).initial",
"internal": false,
"eventType": "RECEIVE_ROOM_CALL"
}
],
"CALL_USER": [
{
"target": [
"#(machine).waiting"
],
"actions": [],
"event": "CALL_USER",
"source": "#(machine).initial",
"internal": false,
"eventType": "CALL_USER"
}
],
"JOIN_ROOM": [
{
"target": [
"#(machine).connecting"
],
"actions": [
{
"type": "joinRoom"
}
],
"event": "JOIN_ROOM",
"source": "#(machine).initial",
"internal": false,
"eventType": "JOIN_ROOM"
}
]
},
"transitions": [
{
"target": [
"#(machine).ringing"
],
"actions": [],
"event": "RECEIVE_CALL",
"source": "#(machine).initial",
"internal": false,
"eventType": "RECEIVE_CALL"
},
{
"target": [
"#(machine).ringing"
],
"actions": [],
"event": "RECEIVE_ROOM_CALL",
"source": "#(machine).initial",
"internal": false,
"eventType": "RECEIVE_ROOM_CALL"
},
{
"target": [
"#(machine).waiting"
],
"actions": [],
"event": "CALL_USER",
"source": "#(machine).initial",
"internal": false,
"eventType": "CALL_USER"
},
{
"target": [
"#(machine).connecting"
],
"actions": [
{
"type": "joinRoom"
}
],
"event": "JOIN_ROOM",
"source": "#(machine).initial",
"internal": false,
"eventType": "JOIN_ROOM"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 1,
"invoke": []
},
"ringing": {
"id": "(machine).ringing",
"key": "ringing",
"type": "atomic",
"history": false,
"states": {},
"on": {
"REJECT": [
{
"target": [
"#(machine).rejected"
],
"event": "REJECT",
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "REJECT"
}
],
"ACCEPT": [
{
"target": [
"#(machine).connecting"
],
"event": "ACCEPT",
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "ACCEPT"
}
],
"WILL_CALL_BACK": [
{
"target": [
"#(machine).willCallBack"
],
"event": "WILL_CALL_BACK",
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "WILL_CALL_BACK"
}
],
"xstate.after(30000)#(machine).ringing": [
{
"target": [
"#(machine).notAnswered"
],
"event": "xstate.after(30000)#(machine).ringing",
"delay": 30000,
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "xstate.after(30000)#(machine).ringing"
}
]
},
"transitions": [
{
"target": [
"#(machine).rejected"
],
"event": "REJECT",
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "REJECT"
},
{
"target": [
"#(machine).connecting"
],
"event": "ACCEPT",
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "ACCEPT"
},
{
"target": [
"#(machine).willCallBack"
],
"event": "WILL_CALL_BACK",
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "WILL_CALL_BACK"
},
{
"target": [
"#(machine).notAnswered"
],
"event": "xstate.after(30000)#(machine).ringing",
"delay": 30000,
"actions": [],
"source": "#(machine).ringing",
"internal": false,
"eventType": "xstate.after(30000)#(machine).ringing"
}
],
"entry": [
{
"type": "xstate.send",
"event": {
"type": "xstate.after(30000)#(machine).ringing"
},
"delay": 30000,
"id": "xstate.after(30000)#(machine).ringing"
}
],
"exit": [
{
"type": "xstate.cancel",
"sendId": "xstate.after(30000)#(machine).ringing"
}
],
"activities": [],
"order": 2,
"invoke": []
},
"notAnswered": {
"id": "(machine).notAnswered",
"key": "notAnswered",
"type": "atomic",
"history": false,
"states": {},
"on": {
"": [
{
"cond": {
"type": "xstate.guard",
"name": "isDesktop"
},
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).notAnswered",
"internal": false,
"eventType": ""
}
]
},
"transitions": [
{
"cond": {
"type": "xstate.guard",
"name": "isDesktop"
},
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).notAnswered",
"internal": false,
"eventType": ""
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 3,
"invoke": []
},
"rejected": {
"id": "(machine).rejected",
"key": "rejected",
"type": "atomic",
"history": false,
"states": {},
"on": {
"": [
{
"cond": {
"type": "xstate.guard",
"name": "isDesktop"
},
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).rejected",
"internal": false,
"eventType": ""
}
]
},
"transitions": [
{
"cond": {
"type": "xstate.guard",
"name": "isDesktop"
},
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).rejected",
"internal": false,
"eventType": ""
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 4,
"invoke": []
},
"willCallBack": {
"id": "(machine).willCallBack",
"key": "willCallBack",
"type": "atomic",
"history": false,
"states": {},
"on": {
"": [
{
"cond": {
"type": "xstate.guard",
"name": "isDesktop"
},
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).willCallBack",
"internal": false,
"eventType": ""
}
]
},
"transitions": [
{
"cond": {
"type": "xstate.guard",
"name": "isDesktop"
},
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).willCallBack",
"internal": false,
"eventType": ""
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 5,
"invoke": []
},
"waiting": {
"id": "(machine).waiting",
"key": "waiting",
"type": "atomic",
"history": false,
"states": {},
"on": {
"PARTICIPANTS_CHANGED": [
{
"cond": {
"type": "xstate.guard",
"name": "cond"
},
"target": [
"#(machine).connecting"
],
"event": "PARTICIPANTS_CHANGED",
"actions": [],
"source": "#(machine).waiting",
"internal": false,
"eventType": "PARTICIPANTS_CHANGED"
},
{
"cond": {
"type": "xstate.guard",
"name": "cond"
},
"target": [
"#(machine).terminated"
],
"event": "PARTICIPANTS_CHANGED",
"actions": [],
"source": "#(machine).waiting",
"internal": false,
"eventType": "PARTICIPANTS_CHANGED"
}
],
"ADDED_TO_CALL": [
{
"target": [
"#(machine).addedToCall"
],
"event": "ADDED_TO_CALL",
"actions": [],
"source": "#(machine).waiting",
"internal": false,
"eventType": "ADDED_TO_CALL"
}
]
},
"transitions": [
{
"cond": {
"type": "xstate.guard",
"name": "cond"
},
"target": [
"#(machine).connecting"
],
"event": "PARTICIPANTS_CHANGED",
"actions": [],
"source": "#(machine).waiting",
"internal": false,
"eventType": "PARTICIPANTS_CHANGED"
},
{
"cond": {
"type": "xstate.guard",
"name": "cond"
},
"target": [
"#(machine).terminated"
],
"event": "PARTICIPANTS_CHANGED",
"actions": [],
"source": "#(machine).waiting",
"internal": false,
"eventType": "PARTICIPANTS_CHANGED"
},
{
"target": [
"#(machine).addedToCall"
],
"event": "ADDED_TO_CALL",
"actions": [],
"source": "#(machine).waiting",
"internal": false,
"eventType": "ADDED_TO_CALL"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 6,
"invoke": []
},
"terminated": {
"id": "(machine).terminated",
"key": "terminated",
"type": "atomic",
"history": false,
"states": {},
"on": {
"CLOSE": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).terminated",
"internal": false,
"eventType": "CLOSE"
}
]
},
"transitions": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).terminated",
"internal": false,
"eventType": "CLOSE"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 7,
"invoke": []
},
"addedToCall": {
"id": "(machine).addedToCall",
"key": "addedToCall",
"type": "atomic",
"history": false,
"states": {},
"on": {
"": [
{
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).addedToCall",
"internal": false,
"eventType": ""
}
]
},
"transitions": [
{
"target": [
"#(machine).closed"
],
"event": "",
"actions": [],
"source": "#(machine).addedToCall",
"internal": false,
"eventType": ""
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 8,
"invoke": []
},
"connecting": {
"id": "(machine).connecting",
"key": "connecting",
"type": "atomic",
"history": false,
"states": {},
"on": {
"CONNECTED": [
{
"target": [
"#(machine).connected"
],
"event": "CONNECTED",
"actions": [],
"source": "#(machine).connecting",
"internal": false,
"eventType": "CONNECTED"
}
],
"ERROR": [
{
"target": [
"#(machine).callError"
],
"event": "ERROR",
"actions": [],
"source": "#(machine).connecting",
"internal": false,
"eventType": "ERROR"
}
]
},
"transitions": [
{
"target": [
"#(machine).connected"
],
"event": "CONNECTED",
"actions": [],
"source": "#(machine).connecting",
"internal": false,
"eventType": "CONNECTED"
},
{
"target": [
"#(machine).callError"
],
"event": "ERROR",
"actions": [],
"source": "#(machine).connecting",
"internal": false,
"eventType": "ERROR"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 9,
"invoke": []
},
"connected": {
"id": "(machine).connected",
"key": "connected",
"type": "atomic",
"history": false,
"states": {},
"on": {
"LEAVE": [
{
"target": [
"#(machine).left"
],
"event": "LEAVE",
"actions": [],
"source": "#(machine).connected",
"internal": false,
"eventType": "LEAVE"
}
],
"ERROR": [
{
"target": [
"#(machine).callError"
],
"event": "ERROR",
"actions": [],
"source": "#(machine).connected",
"internal": false,
"eventType": "ERROR"
}
]
},
"transitions": [
{
"target": [
"#(machine).left"
],
"event": "LEAVE",
"actions": [],
"source": "#(machine).connected",
"internal": false,
"eventType": "LEAVE"
},
{
"target": [
"#(machine).callError"
],
"event": "ERROR",
"actions": [],
"source": "#(machine).connected",
"internal": false,
"eventType": "ERROR"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 10,
"invoke": []
},
"left": {
"id": "(machine).left",
"key": "left",
"type": "atomic",
"history": false,
"states": {},
"on": {
"CLOSE": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).left",
"internal": false,
"eventType": "CLOSE"
}
]
},
"transitions": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).left",
"internal": false,
"eventType": "CLOSE"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 11,
"invoke": []
},
"callError": {
"id": "(machine).callError",
"key": "callError",
"type": "atomic",
"history": false,
"states": {},
"on": {
"RETRY": [
{
"target": [
"#(machine).connecting"
],
"event": "RETRY",
"actions": [],
"source": "#(machine).callError",
"internal": false,
"eventType": "RETRY"
}
],
"CLOSE": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).callError",
"internal": false,
"eventType": "CLOSE"
}
]
},
"transitions": [
{
"target": [
"#(machine).connecting"
],
"event": "RETRY",
"actions": [],
"source": "#(machine).callError",
"internal": false,
"eventType": "RETRY"
},
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).callError",
"internal": false,
"eventType": "CLOSE"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 12,
"invoke": []
},
"error": {
"id": "(machine).error",
"key": "error",
"type": "atomic",
"history": false,
"states": {},
"on": {
"CLOSE": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).error",
"internal": false,
"eventType": "CLOSE"
}
]
},
"transitions": [
{
"target": [
"#(machine).closed"
],
"event": "CLOSE",
"actions": [],
"source": "#(machine).error",
"internal": false,
"eventType": "CLOSE"
}
],
"entry": [],
"exit": [],
"activities": [],
"order": 13,
"invoke": []
},
"closed": {
"id": "(machine).closed",
"key": "closed",
"type": "atomic",
"history": false,
"states": {},
"on": {},
"transitions": [],
"entry": [
{
"type": "close"
}
],
"exit": [],
"activities": [],
"order": 14,
"invoke": []
}
},
"on": {},
"transitions": [],
"entry": [],
"exit": [],
"activities": [],
"order": -1,
"invoke": []
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment