Created
April 2, 2020 14:50
-
-
Save carlosvillu/53bbc285604bb5c20b1bb48373e3c2d7 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 fetchMachine = Machine({ | |
id: 'trackingMachine', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
SHOW_BANNER: { | |
target: 'banner', | |
cond: 'isNotAVisitRejected' | |
}, | |
CLICK_LINK: { | |
target: 'modal', | |
cond: 'isNotAVisitRejected' | |
}, | |
VISIT_REJECTED: { | |
target: 'visitReject', | |
cond: 'isAVisitRejected' | |
} | |
} | |
}, | |
banner: { | |
on: { | |
REVIEW: { | |
target: 'modal' | |
}, | |
ACCEPT: { | |
target: 'accepted' | |
} | |
} | |
}, | |
modal: { | |
on: { | |
ACCEPT: { | |
target: 'accepted' | |
}, | |
REJECT: { | |
target: 'rejected' | |
} | |
} | |
}, | |
accepted: { | |
type: 'final', | |
entry: 'trackAccepted' | |
}, | |
rejected: { | |
type: 'final', | |
entry: 'trackRejected' | |
}, | |
visitReject: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
'': { | |
target: 'trackVisitRejected', | |
cond: 'notTrackVisitRejectOnSession' | |
} | |
} | |
}, | |
trackVisitRejected: { | |
type: 'final' | |
} | |
} | |
} | |
} | |
}, | |
{ | |
actions: { | |
trackAccepted: () => {}, | |
trackRejected: () => {} | |
}, | |
guards: { | |
isNotAVisitRejected: () => { | |
return false | |
}, | |
isAVisitRejected: () => { | |
return true | |
}, | |
notTrackVisitRejectOnSession: () => { | |
return true | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment