Created
April 21, 2020 18:30
-
-
Save ImadBoumzaoued/4238c5f8fd959af3079a92f446077225 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 fetchMachine = Machine({ | |
id: 'login-machine', | |
initial: 'idle', | |
context: { | |
retries: 0, | |
message: undefined | |
}, | |
states: { | |
idle: { | |
on: { | |
LOGIN: 'pending' | |
} | |
}, | |
pending: { | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure' | |
} | |
}, | |
success: { | |
type: 'final' | |
}, | |
failure: { | |
on: { | |
LOGIN: { | |
target: 'pending', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1 | |
}) | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment