Closed petele closed 8 years ago
Where are two options here:
I'm more pro option 1 than 2 simply because we have controlled cases and we have unexpected / bad error cases.
@petele what do you think?
How do other similar APIs that return promises behave?
While I don't love option 1, I can live with it if it's documented extremely well. The docs and samples should all include code snippets that check the success response for a true success.
Spoke to Addy and he's pro option 2 like you so let's roll with that. It'll be demo code that is most important either way. Will look at a PR tomorrow for this hopefully.
My current thinking for this would be this:
library.sendWebPush('Hello, World!', INVALID_SUBSCRIPTION)
.catch(err => {
if (err.code === 'expired-subscription') {
// TODO: Delete your subscription
return;
}
});
Does that seem good @addyosmani @petele ?
Looks good to me! Thanks.
LGTM2
It's in master - thanks all.
If I try to send a push message to a client who has unsubscribed, the promise is fulfilled and I have to look at the response returned. I expected the promise to be rejected and then catch the error there.