Last active
February 11, 2021 03:16
-
-
Save azamara/897d74157295869b5735b7cded0d8668 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 defaultMachine = { | |
id: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { | |
TIMER: 'red' | |
} | |
}, | |
red: { | |
on: { | |
TIMER: 'green' | |
}, | |
} | |
} | |
}; | |
const rootMachine = { | |
id: 'light', | |
initial: 'init', | |
context: { | |
theme: 'light', | |
}, | |
states: { | |
init: { | |
on: { | |
INIT: 'ready' | |
} | |
}, | |
ready: { | |
on: { | |
RUN: { target: '#page' }, | |
RESET: 'init' | |
}, | |
} | |
} | |
} | |
const pageMachine = { | |
id: 'page', | |
type: 'parallel', | |
states: { | |
sidebar: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_BOLD: 'off' } | |
}, | |
off: { | |
on: { TOGGLE_BOLD: 'on' } | |
} | |
} | |
}, | |
content: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_UNDERLINE: 'off' } | |
}, | |
off: { | |
on: { TOGGLE_UNDERLINE: 'on' } | |
} | |
} | |
}, | |
popup: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_ITALICS: 'off' } | |
}, | |
off: { | |
on: { TOGGLE_ITALICS: 'on' } | |
} | |
} | |
}, | |
} | |
} | |
const appMachine = Machine({ | |
id: 'app', | |
initial: 'page', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
start: { | |
on: { | |
LAUNCH: 'root' | |
} | |
}, | |
root: { | |
...rootMachine | |
}, | |
page: { | |
...pageMachine | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment