Skip to content

Instantly share code, notes, and snippets.

@the-main-thing
Last active February 13, 2020 11:58
Show Gist options
  • Save the-main-thing/acebc82d031fbf01cb3358d896ad1692 to your computer and use it in GitHub Desktop.
Save the-main-thing/acebc82d031fbf01cb3358d896ad1692 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const id = 'addNewAgentInCosts';
const addNewAgentInCosts = Machine({
id,
initial: 'idle',
context: {
agentName: ''
},
states: {
idle: {
on: {
ADD: {
target: 'add',
actions: ['setAgentName']
}
}
},
add: {
on: {
CANCEL: 'idle',
CREATE: 'creating'
}
},
creating: {
on: {
DONE: {
target: 'idle',
actions: ['clearContext']
},
ERROR: 'createError'
}
},
createError: {
on: {
CANCEL: 'idle',
CREATE: 'creating'
}
}
},
actions: {
setAgentName: assign({
agentName: (_, { agentName }) => agentName
}),
clearContext: assign({
agentName: () => ''
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment