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

Emitter "succeeding" but returning undefined #29

Closed
robross0606 opened this issue Oct 30, 2019 · 3 comments
Closed

Emitter "succeeding" but returning undefined #29

robross0606 opened this issue Oct 30, 2019 · 3 comments

Comments

@robross0606
Copy link

robross0606 commented Oct 30, 2019

I'm using p-Event like this:

const httpServer = await pEvent(server.koaApp.listen(config.server.port), 'listening')

The 'listening' event is triggering but the result in httpServer is undefined. What am I doing wrong?

@robross0606
Copy link
Author

Also, does p-event have a way to handle situations where the emitter function also returns a value?

@sindresorhus
Copy link
Owner

You might need to bind the .listen method to the koaApp instance:

const httpServer = await pEvent(server.koaApp.listen.bind(server.koaApp, config.server.port), 'listening')

@sindresorhus
Copy link
Owner

Also, does p-event have a way to handle situations where the emitter function also returns a value?

No, I have never seen an API like that, so I don't think it's common enough to support such a thing.

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

No branches or pull requests

2 participants