Skip to content

Instantly share code, notes, and snippets.

@naivefun
Last active July 9, 2021 06:11
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 naivefun/4a68a3bbc3b91ffa44c0b8d4d570a7b2 to your computer and use it in GitHub Desktop.
Save naivefun/4a68a3bbc3b91ffa44c0b8d4d570a7b2 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: "map",
initial: "preview",
context: {
map: {},
devices: [],
deviceId: '',
devicePosition: {x:0, y:0},
buildingId: '',
buildingPoints: []
},
states: {
preview: {
on: {
MANAGE_DEVICES: "deviceManager",
MANAGE_BUILDINGS: "buildingManager",
},
},
deviceManager: {
states: {
idle: {
on: {
DRAG: "dragging",
},
},
moving: {
on: {
DROP: "idle",
CANCEL: "idle",
},
},
dragging: {
on: {
DROP: "idle",
},
},
adding: {
on: {
DROP: "idle",
},
},
},
on: {
SAVE: "preview",
},
},
buildingManager: {
states: {
idle: {
on: {
DRAW: 'drawing'
}
},
drawing: {
on: {
ADD_POINT: 'drawing',
DONE: 'done'
}
},
done: {
on: {
always: 'idle'
}
}
},
on: {
SAVE: "preview",
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment