Last active
May 17, 2022 15:37
-
-
Save louisremi/5f71b213294726d797d1c63c5245ae07 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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions | |
| // - XState (all XState exports) | |
| const fetchMachine = Machine({ | |
| "id": "booking", | |
| "initial": "loadingBooking", | |
| "context": { | |
| "token": null, | |
| "isLate": false, | |
| "bookingId": null, | |
| "booking": null, | |
| "session": null, | |
| "user": null, | |
| "coach": null, | |
| "twilioRoom": null, | |
| "localRef": null, | |
| "remoteRef": null | |
| }, | |
| "states": { | |
| "idle": { | |
| "on": { | |
| "initLoadBooking": "loadingBooking" | |
| } | |
| }, | |
| "loadingBooking": { | |
| "invoke": { | |
| "id": "getBooking", | |
| "src": "getBookingAndMe", | |
| "onDone": { | |
| "target": "validatingDevice", | |
| "actions": { | |
| "type": "xstate.assign", | |
| "assignment": {} | |
| } | |
| }, | |
| "onError": [ | |
| { | |
| "target": "apiErrored", | |
| "actions": "trackError" | |
| }, | |
| { | |
| "target": "bookingErroredEarly" | |
| }, | |
| { | |
| "target": "bookingErroredLate" | |
| } | |
| ] | |
| } | |
| }, | |
| "apiErrored": {}, | |
| "bookingErroredEarly": {}, | |
| "bookingErroredLate": {}, | |
| "validatingDevice": { | |
| "invoke": { | |
| "id": "validateDevice", | |
| "src": "validateDevice", | |
| "onDone": { | |
| "target": "promptingUserMedia" | |
| }, | |
| "onError": [ | |
| { | |
| "target": "promptingNativeApp" | |
| }, | |
| { | |
| "target": "promptingRecentBrowser" | |
| } | |
| ] | |
| } | |
| }, | |
| "promptingNativeApp": { | |
| "on": { | |
| "ignoreNativeApp": { | |
| "target": "promptingUserMedia" | |
| } | |
| } | |
| }, | |
| "promptingRecentBrowser": { | |
| "on": { | |
| "ignoreRecentBrowser": { | |
| "target": "promptingUserMedia" | |
| } | |
| } | |
| }, | |
| "promptingUserMedia": { | |
| "invoke": { | |
| "id": "checkUserMedia", | |
| "src": "checkUserMedia", | |
| "onDone": { | |
| "target": "connectingSession" | |
| }, | |
| "onError": { | |
| "target": "userMediaErrored" | |
| } | |
| } | |
| }, | |
| "userMediaErrored": {}, | |
| "connectingSession": { | |
| "invoke": { | |
| "id": "connectSession", | |
| "src": "connectSession", | |
| "onDone": { | |
| "target": "sessionConnected", | |
| "actions": { | |
| "type": "xstate.assign", | |
| "assignment": {} | |
| } | |
| }, | |
| "onError": { | |
| "target": "apiErrored", | |
| "actions": "trackError" | |
| } | |
| } | |
| }, | |
| "sessionConnected": { | |
| "id": "session", | |
| "type": "parallel", | |
| "entry": "trackConnected", | |
| "invoke": { | |
| "id": "handleRoom", | |
| "src": "handleRoom" | |
| }, | |
| "states": { | |
| "coach": { | |
| "initial": "coachDisconnected", | |
| "states": { | |
| "coachDisconnected": { | |
| "on": { | |
| "coachConnects": "coachConnected" | |
| } | |
| }, | |
| "coachConnected": { | |
| "on": { | |
| "coachDisconnects": "coachDisconnected" | |
| } | |
| } | |
| } | |
| }, | |
| "coachVideo": { | |
| "initial": "coachVideoUnsubscribed", | |
| "states": { | |
| "coachVideoUnsubscribed": { | |
| "on": { | |
| "subscribeCoachVideo": "coachVideoSubscribed" | |
| } | |
| }, | |
| "coachVideoSubscribed": { | |
| "on": { | |
| "unsubscribeCoachVideo": "coachVideoSubscribed" | |
| } | |
| } | |
| } | |
| }, | |
| "coachAudio": { | |
| "initial": "coachAudioUnsubscribed", | |
| "states": { | |
| "coachAudioUnsubscribed": { | |
| "on": { | |
| "subscribeCoachAudio": "coachAudioSubscribed" | |
| } | |
| }, | |
| "coachAudioSubscribed": { | |
| "on": { | |
| "unsubscribeCoachAudio": "coachAudioSubscribed" | |
| } | |
| } | |
| } | |
| }, | |
| "coachee": { | |
| "id": "coachee", | |
| "initial": "isPresent", | |
| "states": { | |
| "isPresent": { | |
| "on": { | |
| "initLeaving": "isLeaving" | |
| } | |
| }, | |
| "isLeaving": { | |
| "on": { | |
| "confirmLeaving": { | |
| "target": "isRating", | |
| "actions": [ | |
| "disconnect", | |
| "trackDisconnected" | |
| ] | |
| }, | |
| "cancelLeaving": "isPresent" | |
| } | |
| }, | |
| "isRating": { | |
| "entry": "trackRatingOpen", | |
| "on": { | |
| "rateCoach": { | |
| "target": "hasRated", | |
| "actions": [ | |
| "postRating", | |
| "trackRatingSent" | |
| ] | |
| } | |
| } | |
| }, | |
| "hasRated": {} | |
| } | |
| }, | |
| "coacheeAudio": { | |
| "id": "coacheeAudio", | |
| "initial": "coacheeAudioOn", | |
| "states": { | |
| "coacheeAudioOn": { | |
| "on": { | |
| "toggleCoacheeAudio": { | |
| "target": "coacheeAudioOff", | |
| "actions": [ | |
| "disableAudio" | |
| ] | |
| } | |
| } | |
| }, | |
| "coacheeAudioOff": { | |
| "on": { | |
| "toggleCoacheeAudio": { | |
| "target": "coacheeAudioOn", | |
| "actions": "enableAudio" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "coacheeVideo": { | |
| "id": "coacheeVideo", | |
| "initial": "coacheeVideoOn", | |
| "states": { | |
| "coacheeVideoOn": { | |
| "on": { | |
| "toggleCoacheeVideo": { | |
| "target": "coacheeVideoOff", | |
| "actions": [ | |
| "disableVideo" | |
| ] | |
| } | |
| } | |
| }, | |
| "coacheeVideoOff": { | |
| "on": { | |
| "toggleCoacheeVideo": { | |
| "target": "coacheeVideoOn", | |
| "actions": [ | |
| "enableVideo" | |
| ] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment