-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Description
Can we please change the code of ClientEngine.start so that it resolves once it's ready?
I was extremely confused that this just wouldn't work:
export default class MyGameClientEngine extends ClientEngine {
// ...
async start() {
await super.start(); // Execution stops right here
this.gameEngine.once('renderer.ready', () => {
// ...
document.querySelector('#joinGame').addEventListener('click', (clickEvent) => {
console.log("CLICK #joinGame");
if (Utils.isTouchDevice()){
this.renderer.enableFullScreen();
}
clickEvent.currentTarget.disabled = true;
this.socket.emit('requestRestart');
});
// ...
});
// ...
}
// ...
}
Or this:
const clientEngine = new MyGameClientEngine(gameEngine, options);
clientEngine.start().then(()=>{
// This doesn't get executed because `ClientEngine.start` doesn't resolve
clientEngine.renderer.setupBackground();
clientEngine.renderer.setRendererSize();
}).catch(console.error);
It seems like a very bad idea to not resolve the promise immediately. (Not to mention that rejecting with undefined makes debugging a nightmare.)
I'd be willing to make a PR, but I wanted to discuss this first.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels