Last active
February 6, 2020 15:59
-
-
Save brayniverse/853ff9922c7c0b0ae4c5eeaf36a01fc5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
const editStates = { | |
initial: 'saved', | |
states: { | |
open: { | |
on: { | |
SAVE: 'saved' | |
} | |
}, | |
saved: { | |
on: { | |
NEW_VERSION_EDIT: 'open', | |
SET_FOR_APPROVAL: 'pendingApproval' | |
} | |
}, | |
pendingApproval: { | |
on: { | |
APPROVE: 'approved', | |
UNSET: 'saved' | |
} | |
}, | |
approved: { | |
on: { | |
PUBLISH: 'published' | |
} | |
}, | |
published: {} | |
} | |
}; | |
const versionStates = Machine({ | |
key: 'version', | |
initial: 'open', | |
states: { | |
saved: { | |
on: { | |
COPY: 'open', | |
SET_FOR_APPROVAL: 'pendingApproval' | |
} | |
}, | |
open: { | |
on: { | |
SAVE: 'saved' | |
} | |
}, | |
pendingApproval: { | |
on: { | |
APPROVE: 'approved', | |
UNSET: 'saved' | |
} | |
}, | |
approved: { | |
on: { | |
PUBLISH: 'published.saved' | |
} | |
}, | |
published: { | |
...editStates | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment