Skip to content

Instantly share code, notes, and snippets.

// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const toggleMachine = Machine(
{
id: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: { TOGGLE: 'active' }
},
active: {
// The 'beeping' activity will take place as long as
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const config = {
key: 'virtual-funding',
initial: 'preparation',
states: {
preparation: {
type: 'parallel',
states: {
prepareJointChannel: {
initial: 'waitForProtocol',
states: {
const config = {
key: 'virtual-fund-as-hub',
initial: 'preFundSetup',
states: {
preFundSetup: {
initial: 'preFundData',
states: {
preFundData: { invoke: { src: 'preFundData', onDone: 'advanceChannel' } },
advanceChannel: {
invoke: {
@andrewgordstewart
andrewgordstewart / machine.js
Last active February 7, 2020 21:28
Generated by XState Viz: https://xstate.js.org/viz
const config = {
key: 'virtual-fund-as-leaf',
initial: 'preFundSetup',
states: {
preFundSetup: {
initial: 'preFundData',
states: {
preFundData: { invoke: { src: 'preFundData', onDone: 'advanceChannel' } },
advanceChannel: {
invoke: {
@andrewgordstewart
andrewgordstewart / machine.js
Last active February 5, 2020 18:37
Generated by XState Viz: https://xstate.js.org/viz
const config = {
key: 'virtual-funding',
initial: 'preFundSetup',
states: {
preFundSetup: {
invoke: {
id: 'preFundSetup',
src: 'advanceChannel',
data: ({ targetChannelId }) => ({
channelId: targetChannelId,
const config = {
key: 'virtual-fund-as-leaf',
initial: 'createChannels',
states: {
createChannels: {
type: 'parallel',
states: {
createGuarantorChannel: {
initial: 'guarantorChannelArgs',
states: {
const config = {
key: 'virtual-funding-as-hub',
initial: 'createChannels',
states: {
createChannels: {
type: 'parallel',
states: {
createLeftGuarantorChannel: {
initial: 'leftGuarantorArgs',
states: {
const machineB = Machine({
initial: 'ready',
states: {
ready: { entry: sendParent({ type: 'CLICK', from: 'machineB' }) },
},
});
const machineC = Machine({
initial: 'ready',
states: {