Last active
October 29, 2019 07:54
-
-
Save nampdn/b4981a13e5bf45f59d8368a0fdee6eea 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 windowMachine = Machine({ | |
initial: "loading", | |
context: { | |
title: "GI 3:16", | |
type: "BIBLE" | |
}, | |
states: { | |
idle: { | |
on: { | |
FETCH: "loading", | |
SHOW: "show", | |
CLOSE: "close" | |
} | |
}, | |
loading: { | |
after: { | |
3000: 'failure.timeout' | |
}, | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure', | |
TIMEOUT: 'failure.timeout' | |
}, | |
meta: { | |
message: 'Loading...' | |
} | |
}, | |
show: { | |
on: { | |
OPEN_MODAL: "modal" | |
} | |
}, | |
modal: { | |
initial: "open", | |
states: { | |
open: { | |
on: { | |
CLOSE: "close" | |
}, | |
}, | |
close: { | |
type: "final" | |
} | |
} | |
}, | |
close: { | |
target: "idle" | |
}, | |
success: { | |
meta: { | |
message: 'The request succeeded!' | |
} | |
}, | |
failure: { | |
initial: 'rejection', | |
states: { | |
rejection: { | |
meta: { | |
message: "The request failed." | |
} | |
}, | |
timeout: { | |
meta: { | |
message: "The request timeout." | |
} | |
} | |
}, | |
meta: { | |
alert: "Uh oh!" | |
} | |
} | |
} | |
}); | |
const windowsMachine = Machine({ | |
id: "windows", | |
initial: "load", | |
context: { | |
list: [] | |
}, | |
states: { | |
load: { | |
on: { | |
LOAD: 'window' | |
} | |
}, | |
window: { | |
...windowMachine | |
}, | |
close: {} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment