Created
August 31, 2020 13:20
-
-
Save NickMele/4ba0e451d46f062a45262dc782c99350 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 fetchMachine = Machine({ | |
id: 'fetch', | |
// Initial state | |
initial: 'idle', | |
// States | |
states: { | |
idle: { | |
on: { | |
FETCH: 'pending' | |
} | |
}, | |
pending: { | |
on: { | |
FULFILL: 'success', | |
REJECT: 'failure' | |
} | |
}, | |
success: { | |
// Initial child state | |
initial: 'items', | |
on: { | |
RELOAD: 'pending' | |
}, | |
// Child states | |
states: { | |
items: { | |
on: { | |
'ITEM.CLICK': 'item' | |
} | |
}, | |
item: { | |
on: { | |
BACK: 'items' | |
} | |
} | |
} | |
}, | |
failure: { | |
on: { | |
RETRY: 'pending' | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment