Last active
January 13, 2021 14:28
-
-
Save dreyescat/38c16eac84dcc27f20263ac5998d4e8c 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'company', | |
initial: 'undefined', | |
context: { | |
name: '', | |
assignedTo: undefined | |
}, | |
states: { | |
undefined: { | |
on: { | |
CREATE: 'created' | |
} | |
}, | |
created: { | |
initial: 'new', | |
on: { | |
DELETE: 'undefined' | |
}, | |
states: { | |
new: { | |
'always': [{ | |
cond: 'isAssigned', | |
target: 'delivered', | |
}, { | |
target: 'backlog' | |
}] | |
}, | |
backlog: { | |
on: { | |
UPDATE: [{ | |
cond: 'isAssigned', | |
target: 'delivered' | |
}] | |
} | |
}, | |
delivered: { | |
on: { | |
UPDATE: [{ | |
cond: 'isUnassigned', | |
target: 'backlog' | |
}] | |
} | |
} | |
} | |
} | |
} | |
}, { | |
guards: { | |
isAssigned: (context, event) => context.assignedTo !== undefined, | |
isUnassigned: (context, event) => context.assignedTo === undefined | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
XState Visualizer