Created
August 18, 2020 10:22
-
-
Save nathanhammond/f6dcf4f3ef92ccec7e0d48ecf335e099 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
var windowId = 0; | |
function windowManager() { | |
return Machine({ | |
id: 'window-manager', | |
initial: 'idle', | |
type: 'parallel', | |
states: { | |
idle: { | |
on: { | |
'OPEN': { | |
target: 'opening', | |
}, | |
'CLOSE': { | |
target: 'closing' | |
}, | |
'FOCUS': { | |
target: 'focusing' | |
} | |
} | |
}, | |
opening: { | |
invoke: [ | |
{ | |
// id: () => { return `${windowId++}` }, | |
id: windowId, | |
src: windowMachine(windowId) | |
} | |
], | |
on: { | |
'COMPLETE': { | |
target: 'idle' | |
} | |
} | |
}, | |
closing: { | |
on: { | |
'COMPLETE': { | |
target: 'idle' | |
} | |
} | |
}, | |
focusing: { | |
on: { | |
'COMPLETE': { | |
target: 'idle' | |
} | |
} | |
} | |
} | |
}); | |
} | |
function windowMachine(name) { | |
return Machine({ | |
id: `window-${name}`, | |
initial: 'loading', | |
states: { | |
loading: {}, | |
unloading: {}, | |
foregrounding: {}, | |
backgrounding: {}, | |
foreground: {}, | |
background: {} | |
} | |
}); | |
}; | |
windowManager(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment