notifme / notifme-sdk

A Node.js library to send all kinds of transactional notifications.
https://notifme.github.io/www/
MIT License
1.94k stars 149 forks source link

send() should return a Promise #1

Closed ibc closed 7 years ago

ibc commented 7 years ago

callbacks and errbacks are not nice, they happen out of context making it difficult to react differently on each send request.

IMHO rather than a global callback/errback, the send() method should return a Promise that resolves with the result of rejects with an Error (or custom Error child depending the failure).

BDav24 commented 7 years ago

Yes, send does return a promise with the result if you don't use a queue system.

See https://github.com/notifme/notifme-sdk/blob/master/src/sender.js#L34 (handleRequest is async)

ibc commented 7 years ago

Oh cool. May be the documentation/README should say that?

BDav24 commented 7 years ago

Yes sure, I'm updating the doc right now ;) Thanks for the feedback.

ibc commented 7 years ago

Thanks.

BDav24 commented 7 years ago

https://github.com/notifme/notifme-sdk/commit/dacdd4b19dbebfb2d8e55c44cfa04c3f85fedfdf