Skip to content

Instantly share code, notes, and snippets.

@VinSpee
Last active November 15, 2019 18:59
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 VinSpee/48e9de94b20eafbeca810e7490f4af3b to your computer and use it in GitHub Desktop.
Save VinSpee/48e9de94b20eafbeca810e7490f4af3b 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 postMachine = Machine({
id: 'post',
initial: 'idle',
context: {
id: undefined,
},
states: {
idle: {
on: {
POST: 'posting'
}
},
posting: {
on: {
POST: {
target: 'posted',
actions: 'post'
},
CANCEL: 'idle',
}
},
posted: {
on: {
EDIT: 'editing',
DELETE: 'deleted',
}
},
editing: {
on: {
POST: {
target: 'posted',
actions: 'edit',
},
CANCEL: 'posted',
DELETE: 'deleted'
}
},
deleted: {
on: {
'': [{
target: 'idle',
actions: 'delete'
}]
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment