Re: [whatwg] Notifications: making requestPermission() return a promise

On Wed, Oct 8, 2014 at 9:51 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> The question is whether it's not natural to assume that *if the promise
> fulfills*, that means they got permission. This allows them to do things
> like using Promise.all() to join multiple permission requests together and
> get a nice combined promise that fulfills when everything succeeds,


This is as simple as:

Promise.all(permissionRequests).then(function(results) {
    if (results.every(x => x === "granted")) // …
});

But I don't think it's the right approach to handling permissions in
general. Developers should handle granted permissions as progressive
enhancements, not balk when they don't get all the permissions they
required. Using exceptions for denied permissions sends a completely wrong
message imho, especially when it's combined with Promise.all.

--tobie

Received on Wednesday, 8 October 2014 08:31:37 UTC