- From: Kostiainen, Anssi <anssi.kostiainen@intel.com>
- Date: Wed, 14 May 2014 08:49:26 +0000
- To: "Sysapps@w3.org" <public-sysapps@w3.org>
- CC: "reeder_29@yahoo.com" <reeder_29@yahoo.com>, Marcos Caceres <w3c@marcosc.com>
On 06 May 2014, at 16:53, Kostiainen, Anssi <anssi.kostiainen@intel.com> wrote: >> Theoretically, permission could change between checking and calling getCurrentLocation, but if I'm calling them in the same tick, ocurrence should be vastly rarer than geolocation failures. > > I think that is not really a concern. I don’t see anything getting in between the following considering the single-threaded nature of JavaScript: > > if (geo.permission === 'enabled') { > geo.getCurrentPosition(); > } > > Or perhaps you have a more complete real life example in mind? Related to this discussion, a proposal by Nikhil elsewhere [1] on how Promise.all() might be used: [[ Promise.all([ Notification.requestPermission(), // Some shimmed form that returns a Promise navigator.push.hasPermission() ]).then(function(perms) { if (perms[0] == 'granted') { // notifications ok; } if (perms[1] == 'granted') { navigator.push.register(); } }); ]] Promise.all() returns a promise that resolves when all of the promises passed to it have resolved. I’m wondering if something like the following has obvious issues: [[ [NoInterfaceObject] interface Permissions { Promise requestPermission (); Promise hasPermission (); /* ... */ }; Notification implements Permissions; PushManager implements Permissions; /* ... */ Geolocation implements Permissions; ]] I think not all APIs can be retrofitted with this, but many could. Thanks, -Anssi [1] https://github.com/w3c/push-api/issues/3#issuecomment-42997477
Received on Wednesday, 14 May 2014 08:51:23 UTC