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

updated: docs, test, source #11

Merged
merged 4 commits into from
Feb 25, 2019
Merged

Conversation

RyLeeHarrison
Copy link
Contributor

No description provided.

Copy link
Contributor

@RangerMauve RangerMauve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR!

One thing that this is missing is that the async methods need to pass callbacks to the actual functions from the client.

When you use Promise.resolve() you're creating a new promise that immediately resolves to undefined since the client's methods expect a callback to be passed in.

Would you mind adding the additional logic from defineAsync where we had makeCallback added to the argument list before passing it to the client's methods?

index.js Outdated
ASYNC_METHODS.forEach(defineAsync);
SYNC_METHODS.forEach(definePassthrough);
async publish (...args) {
return this._client.publish(...args);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still isn't passing a callback to the client. It should look something like this:

Suggested change
return this._client.publish(...args);
return new Promise((resolve, reject) => {
this._client.publish(...args, (err, result) => {
if(err) reject(err)
else resolve(result)
})
})

This will return a promise that only resolves once the publish has been acknowledged by the broker, or will reject if there was a problem.

Without this wrapper, it'd be resolving immediately and the potential error would never be handled.

This should be done with all the async methods.

@RangerMauve
Copy link
Contributor

Nice, it's looking good to me. 😀

I'll do some manual testing later this week and then get this released as a major update.

Thanks again!

@RangerMauve
Copy link
Contributor

Thanks again for the PR! I've released it in 2.2.0

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

Successfully merging this pull request may close these issues.

None yet

2 participants