Skip to content

Instantly share code, notes, and snippets.

@jhampton
Created September 16, 2020 04:19
Show Gist options
  • Save jhampton/a87ec4e7fc8571ac4d747ab9fc1e69fe to your computer and use it in GitHub Desktop.
Save jhampton/a87ec4e7fc8571ac4d747ab9fc1e69fe 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 recorderMachine = Machine({
id: 'recorder',
initial: 'unknown',
context: {
},
states: {
unknown: {
on: {
INIT: 'checkPermission'
}
},
checkPermission: {
on: {
AUTHORIZED: 'unloaded',
NOT_AUTHORIZED: 'noPermission'
}
},
noPermission: {
on: {
RETRY: 'unknown'
}
},
unloaded: {
on: {
SUCCESS: 'ready',
FAILURE: 'unloaded'
}
},
ready: {
on: {
RECORD: 'recording',
UNLOAD: 'unloaded'
}
},
recording: {
on: {
PAUSE: 'paused',
STOP: 'stopped'
}
},
paused: {
on: {
RESUME: 'recording',
STOP: 'stopped'
}
},
stopped: {
on: {
UNLOAD: 'unloaded'
}
}
}
});
// const fetchMachine = Machine({
// id: 'fetch',
// initial: 'idle',
// context: {
// retries: 0
// },
// states: {
// idle: {
// on: {
// FETCH: 'loading'
// }
// },
// loading: {
// on: {
// RESOLVE: 'success',
// REJECT: 'failure'
// }
// },
// success: {
// type: 'final'
// },
// failure: {
// on: {
// RETRY: {
// target: 'loading',
// actions: assign({
// retries: (context, event) => context.retries + 1
// })
// }
// }
// }
// }
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment