Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What do you expect to be waiting for when awaiting evt.post() ? #158

Closed
garronej opened this issue Oct 24, 2020 · 3 comments
Closed

What do you expect to be waiting for when awaiting evt.post() ? #158

garronej opened this issue Oct 24, 2020 · 3 comments
Labels
Question User wanted more information

Comments

@garronej
Copy link
Collaborator

Hi @filfat,

In src/Prismarine.ts what do you expect
when awating this post?

image

Let's say for example I have this scenario:

const em = new EventManager(null as any);

em.on('playerConnect', async () => {

    await new Promise(resolve=> setTimeout(resolve, 100));

    console.log("bar");

});

console.log("foo");

await em.emit('playerConnect', null as any);

console.log("baz");

Do you expect foo bar baz to be printed in the console?
Because currently it would be foo baz bar.

I can make the EventManager behave the way you want it to but I just want to make sure what it is you want exactly. 😊

Cheers

@garronej
Copy link
Collaborator Author

garronej commented Oct 24, 2020

Yes sure sure.
I mean what you want EventManager.prototype.emit() to return is a promise that resolve after all the asynchronous handler have resolved.

I can implement that in the EventManager. As a matter of fact I may make that the default behaviour in Evt 3.0. If would be a much more usefull returned value that the curren 'number of handlers invoked'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question User wanted more information
Projects
None yet
Development

No branches or pull requests

2 participants
@garronej and others