Last active
February 24, 2021 19:42
-
-
Save Jaredk3nt/f0d2a7f37ca1e6f0549054143a66a191 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
const multiPitchMachine = Machine({ | |
id: 'multi-pitch', | |
initial: 'idle', | |
context: { | |
pitches: 0 | |
}, | |
states: { | |
idle: { | |
on: { | |
BELAY: 'belaying', | |
CLIMB: 'climbing', | |
RAPPEL: 'rappelling' | |
} | |
}, | |
belaying: { | |
on: { | |
TAKE: 'taking', | |
SAFE: 'climbing' | |
} | |
}, | |
taking: { | |
on: { | |
BELAY: 'belaying' | |
} | |
}, | |
climbing: { | |
on: { | |
TAKE: 'hanging', | |
TOP: { | |
target: 'idle', | |
actions: assign({ | |
pitches: (context, event) => context.pitches + 1 | |
}) | |
}, | |
TOPOUT: { | |
target: 'success', | |
actions: assign({ | |
pitches: (context, event) => | |
context.pitches + 1 | |
}) | |
} | |
} | |
}, | |
hanging: { | |
on: { | |
CLIMB: 'climbing', | |
LOWER: 'lowering' | |
} | |
}, | |
lowering: { | |
on: { | |
GROUND: 'idle' | |
} | |
}, | |
rappelling: { | |
on: { | |
GROUND: 'bailed' | |
} | |
}, | |
success: { | |
type: 'final' | |
}, | |
bailed: { | |
type: 'final' | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment