Skip to content

Instantly share code, notes, and snippets.

@blorenz
Last active December 12, 2019 16:38
Show Gist options
  • Save blorenz/b24b7a420143defa20a257a808ba5577 to your computer and use it in GitHub Desktop.
Save blorenz/b24b7a420143defa20a257a808ba5577 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const groupGoalMachine = Machine({
id: 'groupGoal',
initial: 'listing',
context: {
goal:null
},
states: {
listing: {
entry: ['emptyGoal'],
on: {
ADD: {target:'adding',
actions: ['newGoal']
},
EDIT: {target:'editing', actions:['editGoal']}
}
},
adding: {
on: {
RESOLVE: 'listing',
REJECT: 'listing'
}
},
editing: {
on: {
RESOLVE: 'listing',
REJECT: 'listing'
}
},
},
},{ actions: {
newGoal:(context, event) => {
context.goal = {}
},
editGoal:(context, event) => {
context.goal = {id: 2, description: 'Hi there'}
} , emptyGoal:(context, event) => {
context.goal = null
}
}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment