Skip to content

Instantly share code, notes, and snippets.

View DaveHudson's full-sized avatar

Dave Hudson DaveHudson

View GitHub Profile
@DaveHudson
DaveHudson / machine.js
Last active August 18, 2020 18:30
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Last active July 27, 2020 13:47
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Last active May 22, 2020 10:40
Generated by XState Viz: https://xstate.js.org/viz
const addItemToCart = (ctx, item) =>
new Promise ((resolve, reject) => {
const newItem = [{
id: ctx.items.length + 1,
name: item.name,
price: item.price,
quantity: item.quantity
}]
const items = [...ctx.items, ...newItem]
@DaveHudson
DaveHudson / machine.js
Last active May 7, 2020 14:17
Generated by XState Viz: https://xstate.js.org/viz
const challengeStates = {
initial: "noMFA",
states: {
noMFA: {
on: {
"": [{ target: "#amplifyAuth.signIn.roleCheck" }],
},
},
mfaSetup: {},
softwareTokenMFA: {},
@DaveHudson
DaveHudson / machine.js
Created December 2, 2019 16:43
Generated by XState Viz: https://xstate.js.org/viz
const applicationMachine = Machine({
id: 'application',
initial: 'idle',
context: {},
states: {
idle: {
on: {
FETCH: 'loading'
}
},
@DaveHudson
DaveHudson / machine.js
Last active December 2, 2019 16:38
Generated by XState Viz: https://xstate.js.org/viz
const applicationMachine = Machine({
id: 'application',
initial: 'idle',
context: {},
states: {
idle: {
on: {
FETCH: 'loading'
}
},
@DaveHudson
DaveHudson / machine.js
Last active December 2, 2019 16:43
Generated by XState Viz: https://xstate.js.org/viz
const formMachine = Machine({
id: 'form',
initial: 'idle',
context: {},
states: {
idle: {
on: {
FETCH: 'loading'
}
},
@DaveHudson
DaveHudson / machine.js
Last active December 2, 2019 16:46
Generated by XState Viz: https://xstate.js.org/viz
const authMachine = Machine({
id: 'auth',
initial: 'signin',
context: {},
states: {
signin: {
on: {
SUBMIT: 'loading'
}
},
@DaveHudson
DaveHudson / machine.js
Last active November 30, 2019 15:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Last active December 1, 2019 18:51
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions