Skip to content

Instantly share code, notes, and snippets.

@happylinks
Last active December 3, 2019 10:26
Show Gist options
  • Save happylinks/96c96b3557bee2f6aa3af62fa2cda9c5 to your computer and use it in GitHub Desktop.
Save happylinks/96c96b3557bee2f6aa3af62fa2cda9c5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const renderStates = {
};
const lightMachine = Machine({
key: 'light',
initial: 'loading',
states: {
loading: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
/* Modify based on response */
success: {
on: {
'': 'idle'
}
},
failure: {
type: 'final'
},
idle: {
on: {
DISCARD_ALL: {
target: 'discarding',
},
PUBLISH_ALL: {
target: 'publishing',
},
DISCARD_SINGLE: {
target: 'idle',
},
SET_VISIBILITY: {
target: 'idle',
},
SET_VALUE: {
target: 'idle',
},
},
initial: 'rendering',
states: {
rendering: {
on: {
ON_PREVIEWER_RENDERED: [
{
target: 'repositioning',
cond: 'hasUnpositionedLayers',
},
{ target: 'rendered' },
],
}
},
repositioning: {
on: {
ON_PREVIEWER_RENDERED: 'rendered'
}
},
rendered: {type: 'final'},
}
},
publishing: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
discarding: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
}
},
}, {
guards: {
'hasUnpositionedLayers': () => true,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment