Player: add message on the vm termination

This commit is contained in:
He4eT 2023-05-25 00:46:22 +03:00 committed by Alexey
commit 7a58f92434
3 changed files with 41 additions and 13 deletions

View file

@ -9,7 +9,7 @@ import GridBuffer from './GridBuffer'
import InputBox from './InputBox'
import Status from './Status'
import { Handlers } from './playerHandlers'
import { Handlers, unhandledRejectionHandler } from './playerHandlers'
import './player.css'
@ -47,20 +47,29 @@ export default function Player ({
const [sendMessage, setSendMessage] = useState(null)
useEffect(() => {
const vm = runMachine({
const handlers = Handlers({
setStatus,
setWindows,
setCurrentWindowId,
setInputType,
setInbox,
})
setVm(runMachine({
engine,
wasmBinary,
storyfile,
handlers: Handlers({
setStatus,
setWindows,
setCurrentWindowId,
setInputType,
setInbox,
}),
})
handlers,
}))
setVm(vm)
const rejectionHandler =
unhandledRejectionHandler(handlers.onExit)
window.addEventListener('unhandledrejection', rejectionHandler)
return () => {
window.removeEventListener('unhandledrejection', rejectionHandler)
}
}, [storyfile, engine, wasmBinary])
useEffect(() => {