Last active
July 29, 2022 17:17
-
-
Save garmjs/2c4b23b2f6485b3f4836919e19fc792e 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 loginMachine = Machine({ | |
id: "loginMachine", | |
initial: "idle", | |
context: { | |
loading: false, | |
data: null | |
}, | |
states: { | |
idle: { | |
on: { | |
SUBMIT: { | |
target: "loading", | |
actions: assign({ | |
loading: true | |
}) | |
} | |
} | |
}, | |
loading: { | |
invoke: { | |
id: "authentication", | |
src: (ctx, event) => {} // removed logic from Visualizer | |
}, | |
on: { | |
SUCCESS: { | |
target: "success", | |
actions: assign({ | |
loading: false, | |
data: (_ctx, event) => event.data | |
}) | |
}, | |
FAIL: { | |
target: "fail", | |
actions: assign({ | |
loading: false, | |
data: (_ctx, event) => event.data | |
}) | |
} | |
} | |
}, | |
success: { | |
type: "final", | |
on: { | |
LOGOUT: { | |
target: "idle" | |
} | |
} | |
}, | |
fail: { | |
on: { | |
CLEAR_ERROR: { | |
actions: assign({ data: () => null }) | |
}, | |
SUBMIT: { | |
target: "loading", | |
actions: assign({ loading: true }) | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment