Last active
December 2, 2019 16:38
-
-
Save DaveHudson/5dbe5be89ebfb27de819303e0f2c7cf5 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
const applicationMachine = Machine({ | |
id: 'application', | |
initial: 'idle', | |
context: {}, | |
states: { | |
idle: { | |
on: { | |
FETCH: 'loading' | |
} | |
}, | |
loading: { | |
on: { | |
RESOLVE: { | |
target: "loaded", | |
actions: assign({ | |
data: (context, event) => event.data | |
}) | |
}, | |
REJECT: { | |
target: "error", | |
actions: assign({ | |
data: (context, event) => event.data | |
}) | |
}, | |
} | |
}, | |
loaded: { | |
on: { | |
SAVE: 'saving' | |
} | |
}, | |
saving: { | |
on: { | |
RESOLVE: { | |
target: "saved", | |
actions: assign({ | |
data: (context, event) => event.data | |
}) | |
}, | |
REJECT: { | |
target: "error", | |
actions: assign({ | |
data: (context, event) => event.data | |
}) | |
}, | |
} | |
}, | |
saved: { | |
type: 'final' | |
}, | |
error: { | |
type: 'final' | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment