Re: [w3c/manifest] Add installation prompt control flow (#417)

> Note that we still need userChoice on the event, because it is used to tell us about the user's choice when the banner is automatically shown.

Good point. If prompt becomes a sync call, then it simplifies things to:

```
window.onbeforeinstallprompt = async function(e) {
  if (thingsTheUserIsDoingThatBlockInstall.length) {
    e.preventDefault();
    await Promise.all(thingsTheUserIsDoingThatBlockInstall);
    e.prompt();
  }
  const { userChoice: choice } = await e.userChoice;
  switch (choice) {
    case "dismissed":
      // The user didn't want the app 😢
      analytics({ userHatesUs: true });
      break;
    case "accepted":
      // Awesome! it's installing
      analytics({ userHatesUs: false });
      break;
    default:
      console.error(`Unknown choice? ${choice}`);
  }
};
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/417#issuecomment-254090538

Received on Monday, 17 October 2016 01:03:32 UTC