Skip to content

Instantly share code, notes, and snippets.

@pangratz
Created April 22, 2020 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pangratz/ab1588a862a33da66277cb2d7cb2a4d5 to your computer and use it in GitHub Desktop.
Save pangratz/ab1588a862a33da66277cb2d7cb2a4d5 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',
SHOW_DAY: {
actions: ['showDay']
},
SHOW_TODAY: {
actions: ['showToday']
},
SHOW_WEEK: {
actions: ['showWeek']
},
SHOW_BEFORE: {
actions: ['showPeriodBefore']
},
SHOW_AFTER: {
actions: ['showPeriodAfter']
}
}
},
editing: {
type: 'parallel',
on: {
STOP_EDITING: 'show'
},
states: {
behavior: {
states: {
idle: {
on: {
SAVE: {
target: 'saving',
actions: ['saveProductionOrders']
}
}
},
saving: {
on: {
SAVE_SUCCESS: 'idle',
SAVE_ERROR: {
target: 'error',
actions: ['showError']
}
}
},
error: {
on: {
SAVE: {
target: 'saving',
actions: ['saveProductionOrders']
}
}
}
}
},
list: {
initial: 'no_selection',
states: {
no_selection: {
on: {
SELECTION_UPDATED: [
{
actions: ['setSelection']
},
{
target: 'has_selection',
cond: 'notEmptySelection'
}
]
}
},
has_selection: {
on: {
SELECTION_UPDATED: [
{
actions: ['setSelection']
},
{
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: ['addSelectionToPlanningPeriodItem']
},
MOVE_UP: {
actions: ['moveProductionOrderPositionUp']
},
MOVE_DOWN: {
actions: ['moveProductionOrderPositionDown']
},
REMOVE_FROM_PLANNING: {
actions: ['setProductionOrderStatusToNew']
}
}
},
detail_modal: {
initial: 'hidden',
states: {
hidden: {
on: {
SHOW_DETAIL_MODAL: {
target: 'showing',
actions: ['showDetailModal']
}
}
},
showing: {
on: {
HIDE_DETAIL_MODAL: {
target: 'hidden',
actions: ['hideDetailModal']
}
}
}
}
}
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment