Last active
June 26, 2020 09:42
-
-
Save edygar/051b1f60db29914476b43a0e3a902333 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'PostingFormPriceEvaluationField', | |
initial: 'idle', | |
context: { | |
featuresValues: {}, | |
missingFeatures: [], | |
evaluation: null, | |
}, | |
states: { | |
idle: { | |
entry: 'FEATURES_CHANGED', | |
on: { | |
FEATURES_CHANGED: { | |
target: 'pending', | |
actions: 'setData', | |
cond: 'checkFilledData' | |
} | |
}, | |
}, | |
evaluationUnavailable: { | |
on: { | |
FEATURES_CHANGED: { | |
target: 'pending', | |
actions: 'setData', | |
cond: 'checkFilledData' | |
} | |
}, | |
}, | |
pending: { | |
invoke: { | |
id: 'fetchRangeForFeatures', | |
src: 'fetchRangeForFeatures', | |
onDone: { | |
target: 'fulfilled' , | |
actions: 'setRange' | |
}, | |
onError: 'rejected' | |
} | |
}, | |
rejected: { | |
on: { | |
FEATURES_CHANGED: { | |
target: 'pending', | |
actions: 'setData', | |
cond: 'checkFilledData' | |
} | |
} | |
}, | |
fulfilled: { | |
initial: 'missingPrice', | |
on: { | |
FEATURES_CHANGED: { | |
target: 'pending', | |
actions: 'setData', | |
cond: 'checkFilledData' | |
} | |
}, | |
states: { | |
missingPrice: { | |
on: { | |
'': { | |
target: 'evaluationShown', | |
cond: 'hasPrice' | |
}, | |
'PRICE_SET': { | |
target: 'evaluationShown', | |
actions: 'setPrice' | |
}, | |
} | |
}, | |
evaluationShown: {}, | |
} | |
} | |
} | |
}, { | |
services: { | |
}, | |
actions: { | |
setPrice() {}, | |
setData() {}, | |
setEvaluation() {}, | |
}, | |
guards: { | |
checkFilledData() { return true }, | |
hasPrice() { return true } | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment