Last active
February 9, 2021 18:58
-
-
Save eduardoleal/74d20caafb5bf93ea981fed73591292d 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: 'lifecycle', | |
initial: 'pending', | |
states: { | |
pending: { | |
on: { | |
ACTIVATE: 'active', | |
PURGE: 'purged', | |
} | |
}, | |
active: { | |
type: 'compound', | |
initial: 'unknown', | |
// Child states | |
states: { | |
unknown: { | |
on: { | |
'': [ | |
{ target: 'premium', cond: 'isPreemium' }, | |
{ target: 'freemium' } | |
] | |
} | |
}, | |
freemium: { | |
on: { | |
upgrade: 'premium' | |
} | |
}, | |
premium: {} | |
}, | |
on: { | |
FREEZE: 'frozen', | |
} | |
}, | |
frozen: { | |
on: { | |
PARTIALLY_BLOCKS: 'partiallyBlocked', | |
REACTIVATE: 'active', | |
} | |
}, | |
partiallyBlocked: { | |
on: { | |
BLOCKS: 'blocked', | |
REACTIVATE: 'active', | |
} | |
}, | |
blocked: { | |
on: { | |
CANCEL: 'canceled', | |
REACTIVATE: 'active', | |
} | |
}, | |
canceled: { | |
on: { | |
PURGE: 'purged', | |
REACTIVATE: 'active', | |
}, | |
}, | |
purged: { | |
type: 'final', | |
}, | |
} | |
}, { | |
guards: { | |
isFreemium: () => false, | |
isPreemium: () => true, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment