Last active
December 12, 2019 16:38
-
-
Save blorenz/b24b7a420143defa20a257a808ba5577 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
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