Skip to content

Instantly share code, notes, and snippets.

@xavhan
Last active October 15, 2020 13:57
Show Gist options
  • Save xavhan/9b21333bd4fc16895d9451b6d90a1b9b to your computer and use it in GitHub Desktop.
Save xavhan/9b21333bd4fc16895d9451b6d90a1b9b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const campaignStateMachine = Machine({
id: 'Campaign state',
initial: 'draft',
guards: {
beforeActivation: (c,e) => false,
inActivation: (c,e) => true,
afterDeactivation: (c,e) => false,
},
states: {
draft: {
on: {
SHARE: 'shared'
}
},
shared: {
initial: 'always',
always: [
{ target: 'pending', cond: 'false' },
{ target: 'active', cond: 'true' },
{ target: 'ended', cond: 'false' }
],
states: {
pending: {
on: {
ACTIVATE: 'active'
}
},
active: {
on: {
DEACTIVATE: 'ended'
}
},
ended: {},
},
on: {
DISABLE: 'disabled'
}
},
disabled: {
on: {
ENABLE: 'shared',
DELETE: 'deleted',
},
},
deleted: {
type: 'final'
},
}
}, {
true: () => true,
false: () => false,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment