Created
March 5, 2021 11:21
-
-
Save mathewtrivett/7622d98fa19cd573e972402fe3389990 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const createAccount = Machine({ | |
id: 'createAccount', | |
initial: 'init', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
init: { | |
on: { | |
NEXT: 'email' | |
} | |
}, | |
email: { | |
on: { | |
NEXT: { | |
target: 'mobile' | |
} | |
} | |
}, | |
mobile: { | |
on: { | |
SEND_OTP: { | |
target: 'sendingOTP', | |
} | |
} | |
}, | |
sendingOTP: { | |
initial: 'sending', | |
states: { | |
sending: { | |
on: { | |
RESOLVE: { | |
target: 'success' | |
}, | |
REJECT: { | |
target: 'failure' | |
} | |
} | |
}, | |
success: {}, | |
failure: {} | |
}, | |
}, | |
failure: { | |
on: { | |
RETRY: { | |
target: 'init', | |
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