Last active
March 22, 2020 22:55
-
-
Save devstojko/c0a6df530de66c2cf067a4a31a676bf5 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const trip = { | |
companyName: '', | |
accommodations: [] | |
} | |
const fetchPrice = () => fetch(WITHOUT_FIRST_TRIP).then(response => response.json()); | |
const basketMachine = Machine({ | |
id: 'basketMachine', | |
initial: 'selectRoute', | |
context: { | |
allowedCompany: null, | |
routes: [trip], | |
hasSelectedRoutes: false, | |
}, | |
states: { | |
selectRoute: { | |
on: { | |
SELECT_ROUTE: { | |
actions: () => {} | |
}, | |
CHANGE_STATE: { | |
target: 'selectAccommodation' | |
} | |
} | |
}, | |
selectAccommodation: { | |
on: { | |
SELECT_ACCOMMODATION: { | |
}, | |
CHANGE_STATE: { | |
target: 'selectRoute' | |
} | |
} | |
} | |
} | |
}, | |
{ | |
guards: { | |
hasSelectedRoutes: () => false | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment