Skip to content

Instantly share code, notes, and snippets.

View CodingDive's full-sized avatar
🎯
Focusing

Mikey Stengel CodingDive

🎯
Focusing
View GitHub Profile
@CodingDive
CodingDive / machine.js
Last active May 5, 2020 14:47
Generated by XState Viz: https://xstate.js.org/viz
const userHardinessZoneMachine = Machine({
id: 'userHardinessZone',
initial: 'idle',
states: {
idle: {
on: {
FETCH: 'loading'
}
},
@CodingDive
CodingDive / machine.js
Last active December 20, 2019 00:48
Generated by XState Viz: https://xstate.js.org/viz
const catFetchMachine = Machine({
id: 'catFetch',
initial: 'idle',
context: {
errorMessage: undefined,
cats: [],
},
states: {
idle: {
on: {
@CodingDive
CodingDive / machine.js
Last active December 17, 2019 15:57
Generated by XState Viz: https://xstate.js.org/viz
const thermostatMachine = Machine(
{
id: 'thermostat',
initial: 'inactive',
context: {
temperature: 20,
},
states: {
inactive: {
on: {
@CodingDive
CodingDive / machine.js
Created December 16, 2019 20:47
Generated by XState Viz: https://xstate.js.org/viz
const thermostatMachine = Machine(
{
id: 'thermostat',
initial: 'inactive',
context: {
temperature: 20,
},
states: {
inactive: {
on: {
@CodingDive
CodingDive / machine.js
Last active December 16, 2019 20:45
Generated by XState Viz: https://xstate.js.org/viz
const thermostatMachine = Machine({
id: 'thermostat',
initial: 'inactive',
context: {
temperature: 20,
},
states: {
inactive: {
on: {
POWER_TOGGLE: 'active'
@CodingDive
CodingDive / machine.js
Created December 14, 2019 16:50
Generated by XState Viz: https://xstate.js.org/viz
const thermostatMachine = Machine({
id: 'thermostat',
initial: 'inactive',
context: {
temperature: 20,
},
states: {
inactive: {
on: {
POWER_TOGGLE: 'active'
@CodingDive
CodingDive / rejectedPromiseInXStateMachineExample.ts
Last active November 19, 2019 21:50
Promise error and notification handling in xstate + react
import { useMachine } from '@xstate/react'
const { sendNotification } = useContext(notificationContext)
const [state, send] = useMachine(
fetchMachine.withConfig({
actions: {
sendErrorNotification: (ctx, e) => {
sendNotification(NOTIFICATION_SEVERITY.ERROR, e.data.message);
},
},
}),
@CodingDive
CodingDive / machine.js
Created September 18, 2019 17:27
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@CodingDive
CodingDive / machine.js
Last active September 18, 2019 15:43
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@CodingDive
CodingDive / machine.js
Last active December 8, 2019 21:24
Generated by XState Viz: https://xstate.js.org/viz
const videoChatMachine = Machine({
id: 'videoChat',
initial: 'audioDisabledVideoDisabled',
states: {
audioDisabledVideoDisabled: {
on: {
ENABLE_VIDEO: 'audioDisabledVideoEnabled',
ENABLE_AUDIO: 'audioEnabledVideoDisabled'
}
},