Last active
November 15, 2019 18:59
-
-
Save VinSpee/48e9de94b20eafbeca810e7490f4af3b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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