Last active
November 6, 2019 09:50
-
-
Save EliaECoyote/e13a8d77ddf43fca0c3f6bc1c1e61a0b 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
"use strict"; | |
// machine state definitions | |
var States; | |
(function (States) { | |
States["idle"] = "idle"; | |
States["userLogged"] = "userLogged"; | |
States["userUnlogged"] = "userUnlogged"; | |
States["startTimePending"] = "startTimePending"; | |
States["startTimeReady"] = "startTimeReady"; | |
})(States || (States = {})); | |
// machine events definitions | |
var Events; | |
(function (Events) { | |
Events["userBecameLogged"] = "userBecameLogged"; | |
Events["userBecameUnlogged"] = "userBecameUnlogged"; | |
Events["startTimeFetchStarted"] = "startTimeFetchStarted"; | |
Events["starTimeReceived"] = "starTimeReceived"; | |
})(Events || (Events = {})); | |
// assigners fns | |
const receiveStartTimeAction = assign({ | |
startTime: (_, event) => event.startTime, | |
}); | |
// machine visualizer: https://xstate.js.org/viz/?gist=e13a8d77ddf43fca0c3f6bc1c1e61a0b | |
const continueWatchProgressMachine = Machine({ | |
id: 'continueWatchProgressMachine', | |
initial: States.idle, | |
context: {}, | |
states: { | |
[States.idle]: { | |
on: { | |
[Events.userBecameLogged]: States.userLogged, | |
[Events.userBecameUnlogged]: States.userUnlogged, | |
}, | |
}, | |
[States.userUnlogged]: { | |
entry: assign({ startTime: () => 0 }), | |
on: { | |
[Events.userBecameLogged]: States.userLogged, | |
}, | |
}, | |
[States.userLogged]: { | |
on: { | |
'': States.startTimePending, | |
}, | |
}, | |
[States.startTimePending]: { | |
entry: assign({ startTime: () => undefined }), | |
on: { | |
[Events.userBecameUnlogged]: States.userUnlogged, | |
[Events.starTimeReceived]: { | |
actions: receiveStartTimeAction, | |
target: States.startTimeReady, | |
}, | |
}, | |
}, | |
[States.startTimeReady]: { | |
on: { | |
[Events.userBecameUnlogged]: States.userUnlogged, | |
[Events.startTimeFetchStarted]: States.startTimePending, | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment