-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add async await syntax. #57
Conversation
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 might be missing some stuff but I'm not fully seeing the benefits here
@@ -302,12 +302,12 @@ class Webhook { | |||
if ( | |||
messageBuilder.data.text // Check for any text | |||
) { | |||
return this.sendPayload(messageBuilder.data, resolve); | |||
return await this.sendPayload(messageBuilder.data, resolve); |
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.
Do we still need a resolve function? This was messy when I wrote it and still is.
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.
Then this should be resolved in future commits. Not in this pr.
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.
No, this resolve function was introduced with the old async system, it's just unused now.
If we introduce async/await syntax then we go all the way, we don't mess around with old style promises and new style.
Accidentally marked as approved |
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.
See comments above
Also looks like there is a gnarly eslint error in there |
The benefit is to use async and await syntax. As discussed. This pr is just to introduce them and make it available. It does not fix bad coding decisions nor any logical errors. This should be handled by other pull requests. |
@Exitare the implementation you have proposed is broken. It does not work at all, I appreciate another PR should fix "poor coding decisions" but this is not working by any means.
|
That wasn’t meant to be rude. Anyways, I don’t have any time to spare in the foreseeable future and therefore will close this PR. If someone would like to take over feel free to do that. |
I'll look into it. I do agree though that the current async system is iffy, if it is reimplemented it should be a full rewrite of all the promises. |
Add the possibility to use async/await as discussed in #56
E.g.
`
const Hook: webhook.Webhook = new webhook.Webhook("WEBHOOK URL");
const msg = new webhook.MessageBuilder().setAuthor("TEST_AUTHOR");
await Hook.send(msg);
`