Last active
April 21, 2020 06:47
-
-
Save awchjimmy/86d8722c388d4f6cfc02049828861365 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 openedIssue = () => { | |
return false; | |
} | |
const closedIssue = () => { | |
return true; | |
} | |
const workInProgress = () => { | |
return true; | |
} | |
const loginMachine = { | |
id: 'login', | |
initial: '尚未登入', | |
states: { | |
'尚未登入': { | |
on: { | |
'我要註冊': '註冊流程', | |
'登入': { | |
target: '登入中。。。', | |
cond: openedIssue | |
} | |
} | |
}, | |
'註冊流程': { | |
}, | |
'登入中。。。': { | |
on: { | |
'登入成功': { | |
target: '登入流程完成', | |
actions: [assign({loginStatus: 'LOGGED_IN'})] | |
}, | |
'登入失敗': '尚未登入' | |
} | |
}, | |
'登入流程完成': { | |
type: 'final' | |
} | |
} | |
} | |
const photoWallMachine = { | |
id: 'photoWall', | |
initial: '照片牆 F', | |
states: { | |
'照片牆 F': { | |
on: { | |
'【點擊】個人照片 F': { | |
target: '播影片 F。。。', | |
cond: closedIssue | |
}, | |
'【點擊】照片牆 M': { | |
target: '照片牆 M', | |
cond: closedIssue | |
} | |
} | |
}, | |
'照片牆 M': { | |
on: { | |
'【點擊】個人照片 M': { | |
target: '全螢幕播影片 M', | |
cond: openedIssue | |
}, | |
'【點擊】照片牆 F': { | |
target: '照片牆 F', | |
cond: closedIssue | |
} | |
} | |
}, | |
'播影片 F。。。': { | |
on: { | |
'【返回】照片牆 F': { | |
target: '照片牆 F', | |
cond: closedIssue | |
}, | |
'影片結束': { | |
target: '設定下一位中。。。', | |
cond: workInProgress | |
} | |
} | |
}, | |
'設定下一位中。。。': { | |
on: { | |
'設定下一位完成': '播影片 F。。。' | |
} | |
}, | |
'全螢幕播影片 M': { | |
on: { | |
'【返回】照片牆 M': { | |
target: '照片牆 M', | |
cond: openedIssue | |
} | |
} | |
} | |
}, | |
} | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'idle', | |
type: 'parallel', | |
context: { | |
loginStatus: 'NOT_LOGGED_IN', | |
userEmail: 'awchjimmy@gmail.com', | |
userPhoneLast3Digits: 506, | |
userFirstChoice: 15, | |
userSecondChoice: 23, | |
currentPlayingVideoIndexFemale: 2, | |
}, | |
states: { | |
'登入流程': { | |
...loginMachine | |
}, | |
'照片牆': { | |
...photoWallMachine | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment