-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Support for async subscriber callbacks #132
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
Conversation
Add support for async subscriber callbacks while retaining backwards compatibility
Looks great! Will probably be a few weeks before this can be reviewed and merged. I won't have time to do it before going on summer vacations and the other maintainers are already on vacations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Please add tests for handling both async and non async callbacks.
Okay. I looked at the existing tests, and I couldn't find enough inspiration to get started with this easily. Do you have an idea of where I can start? The existing tests don't seem to have an example that tests the return value of the callback itself, and if that is being replied. |
Something like this should work
Not the prettiest tests, but without changing the return values we have no way of awaiting everything, so there's a magic 10 ms timeout. |
I added them now, and they pass. Thank you. I also fixed formatting from not working on my machine (and not triggering for TS files either), since I didn't have certain CLIs installed. Did this by switching a precommit into using "NPX" instead. Let me know if that's too much, and I'll remove it again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't actually test the test properly yesterday. It incorrectly passed even when a promise was sent as a response to publishReply, and didn't correctly check the value either. Adding the promises as return value for the function and awaiting (With some other changes) made the tests work as intended.
Good catch with .ts missing from lint-staged. I wonder why you need npx
in the command though - could you check that you've done npm install
(Or 'yarn' if that's what you're using) and that it's simply not missing the needed node modules? Otherwise I'll investigate if there might be any issues with using npx
together with Yarn.
Co-authored-by: Lars Johansson <gismya@gmail.com>
Co-authored-by: Lars Johansson <gismya@gmail.com>
Co-authored-by: Lars Johansson <gismya@gmail.com>
Co-authored-by: Lars Johansson <gismya@gmail.com>
Incorrectly copied the fix when suggesting line by line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some mistakes when line by line suggesting the promise returns. I've commited the correct implementation.
You can remove the changes to package.json - we identified that the commit hooks have more issues and I'm posting a separate PR for that shortly. Thank you for pointing that out! Our IDE setups made us miss that it didn't run correctly.
Thanks for this! |
Add support for async subscriber callbacks while retaining backwards compatibility.
Changes
Made it possible to have an async subscriber callback.
Test
Check if subscribers are still called.