Skip to content

Instantly share code, notes, and snippets.

@pangratz
Last active April 22, 2020 07:33
Show Gist options
  • Save pangratz/71a57b301c8590d5500d62e7ff62cda5 to your computer and use it in GitHub Desktop.
Save pangratz/71a57b301c8590d5500d62e7ff62cda5 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 fetchMachine = Machine({
initial: 'idle',
states: {
idle: {
on: {
LOAD_PRODUCTION_ORDERS: 'loading'
}
},
loading: {
LOADED: 'show'
},
show: {
initial: 'show',
states: {
show: {
on: {
START_EDITING: 'editing'
}
},
editing: {
type: 'parallel',
on: {
STOP_EDITING: 'show'
},
states: {
behavior: {
states: {
idle: {
on: {
SAVE: 'saving'
}
},
saving: {
on: {
SAVE_SUCCESS: 'idle',
SAVE_ERROR: 'error'
}
},
error: {
on: {
SAVE: 'saving'
}
}
}
},
list: {
initial: 'no_selection',
states: {
no_selection: {
on: {
SELECTION_UPDATED: {
target: 'has_selection',
cond: 'notEmptySelection'
}
}
},
has_selection: {
on: {
SELECTION_UPDATED: {
target: 'no_selection',
cond: 'emptySelection'
}
}
}
}
},
content: {
on: {
SHOW_DAY: {
actions: ['showDay']
},
SHOW_TODAY: {
actions: ['showToday']
},
SHOW_WEEK: {
actions: ['showWeek']
},
SHOW_BEFORE: {
actions: ['showPeriodBefore']
},
SHOW_AFTER: {
actions: ['showPeriodAfter']
},
ADD_SELECTION_TO_PLANNING: {
actions: ['addSelectionToScheduleItem']
},
MOVE_UP: {
actions: ['moveProductionOrderPositionUp']
},
MOVE_DOWN: {
actions: ['moveProductionOrderPositionDown']
},
REMOVE_FROM_PLANNING: {
actions: ['setProductionOrderStatusToNew']
}
}
},
detail_modal: {
initial: 'hidden',
states: {
hidden: {
on: {
SHOW_DETAIL_MODAL: 'showing'
}
},
showing: {
on: {
HIDE_DETAIL_MODAL: 'hidden'
}
}
}
}
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment