Last active
March 17, 2020 07:19
-
-
Save jstarrdewar/8e9c8962076e127de9ecffa488ec7e17 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 history = []; | |
const appMachine = Machine({ | |
id: 'App', | |
initial: 'Off', | |
states: { | |
Off: { | |
on: { | |
Start: 'CheckKillSwitch', | |
} | |
}, | |
CheckKillSwitch: { | |
on: { | |
VersionCheckFail: 'UpdateRequired', | |
VersionCheckPass: 'MotionLogo' | |
} | |
}, | |
MotionLogo: { | |
on: { | |
MotionLogoCompleted: 'RestoreUserSessions' | |
} | |
}, | |
UpdateRequired: { | |
type: 'final' | |
}, | |
RestoreUserSessions: { | |
on: { | |
NoRestoredSessions: 'GetStarted', | |
OneRestoredSession: 'CheckUserSessionIsValid', | |
MultipleRestoredSessions: 'SelectUserSession', | |
} | |
}, | |
SelectUserSession: { | |
on: { | |
UserSessionSelected: 'CheckUserSessionIsValid', | |
} | |
}, | |
CheckUserSessionIsValid: { | |
on: { | |
RestoredUserSessionIsValid: 'CheckDateOfBirthIsSet', | |
RestoredUserSessionWasInvalid: 'InvalidUserSession', | |
} | |
}, | |
CheckDateOfBirthIsSet: { | |
on: { | |
UserBirthdayNotSet: 'SignUp', | |
UserHasBirthday: 'CheckOnboardingComplete' | |
} | |
}, | |
InvalidUserSession: { | |
on: { | |
PairAgain: 'Pairing', | |
Back: 'RestoreUserSessions', | |
} | |
}, | |
GetStarted: { | |
on: { | |
GET_STARTED: 'Onboarding', | |
SIGN_IN: 'LoginAppOptional', | |
} | |
}, | |
CheckOnboardingComplete: { | |
on: { | |
OnboardingCompleted: 'MainApp', | |
FALSE: 'Onboarding' | |
} | |
}, | |
Onboarding: { | |
on: { | |
OnBoardingCompleted: 'MainApp', | |
COMPLETED_GUEST: 'SelectMembershipTier' | |
} | |
}, | |
SelectMembershipTier: { | |
on: { | |
GUEST: 'SignUp', | |
PREMIUM: 'GetApp', | |
ALREADY_MEMBER: 'LoginAppOptional' | |
} | |
}, | |
LoginAppOptional: { | |
on: { | |
HAS_APP: 'Pairing', | |
NO_APP: 'SignIn', | |
REQUEST_APP: 'GetApp', | |
} | |
}, | |
GetApp: { | |
on: { | |
HAS_APP: 'Pairing' | |
} | |
}, | |
SignUp: { | |
on: { | |
COMPLETE: 'MainApp' | |
} | |
}, | |
SignIn: { | |
on: { | |
SUCCESS: 'MainApp', | |
FORGOT_PWD: 'ForgotPassword' | |
} | |
}, | |
ForgotPassword: { | |
on: { | |
NOT_FOUND: 'SignUp' | |
} | |
}, | |
MainApp: {}, | |
Pairing: { | |
on: { | |
PairingSuccessful: 'CheckOnboardingComplete', | |
PairingFailed: 'Pairing' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment