Last active
January 25, 2020 00:56
-
-
Save zainfathoni/a3583755d1251d5888b59f84db5c396b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 fetchSuccess = assign({ | |
order: (context, event) => event.order | |
}) | |
const fetchMachine = Machine({ | |
id: 'dvt', | |
initial: 'loading', | |
context: { | |
uuid: '1234-5678-8901-2345', | |
order: {} | |
}, | |
states: { | |
loading: { | |
on: { | |
PENDING: { | |
target: 'confirmOrder', | |
actions: 'fetchSuccess' | |
}, | |
VERIFIED: 'verified', | |
CANCELLED: 'cancelled', | |
EXPIRED: 'expired' | |
} | |
}, | |
verified: { | |
type: 'final' | |
}, | |
cancelled: { | |
type: 'final' | |
}, | |
expired: { | |
type: 'final' | |
}, | |
confirmOrder: { | |
on: { | |
CONFIRM: 'geocoding', | |
CANCEL: 'cancelled' | |
} | |
}, | |
geocoding: { | |
on: { | |
SUCCESS: 'confirmAddress', | |
FAILURE: 'confirmOrder' | |
} | |
}, | |
confirmAddress: { | |
on: { | |
EDIT: 'editAddressMap', | |
CONFIRM: 'confirming' | |
} | |
}, | |
confirming: { | |
on: { | |
SUCCESS: 'verified', | |
FAILURE: 'confirmAddress' | |
} | |
}, | |
editAddressMap: { | |
on: { | |
CONFIRM: 'reverseGeocoding', | |
CANCEL: 'cancelled' | |
} | |
}, | |
reverseGeocoding: { | |
on: { | |
SUCCESS: 'editAddressDetails', | |
FAILURE: 'editAddressMap' | |
} | |
}, | |
editAddressDetails: { | |
on: { | |
SUBMIT: 'updating', | |
CANCEL: 'cancelled' | |
} | |
}, | |
updating: { | |
on: { | |
SUCCESS: 'verified', | |
FAILURE: 'editAddressDetails' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment