Skip to content

Instantly share code, notes, and snippets.

@brayniverse
Last active February 6, 2020 15:59
Show Gist options
  • Save brayniverse/853ff9922c7c0b0ae4c5eeaf36a01fc5 to your computer and use it in GitHub Desktop.
Save brayniverse/853ff9922c7c0b0ae4c5eeaf36a01fc5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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