{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/ServiceWorker/issues/770","repository_url":"https://api.github.com/repos/w3c/ServiceWorker","labels_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/770/labels{/name}","comments_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/770/comments","events_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/770/events","html_url":"https://github.com/w3c/ServiceWorker/issues/770","id":113762437,"number":770,"title":"registration.ready promise","user":{"login":"jakearchibald","id":93594,"avatar_url":"https://avatars.githubusercontent.com/u/93594?v=3","gravatar_id":"","url":"https://api.github.com/users/jakearchibald","html_url":"https://github.com/jakearchibald","followers_url":"https://api.github.com/users/jakearchibald/followers","following_url":"https://api.github.com/users/jakearchibald/following{/other_user}","gists_url":"https://api.github.com/users/jakearchibald/gists{/gist_id}","starred_url":"https://api.github.com/users/jakearchibald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakearchibald/subscriptions","organizations_url":"https://api.github.com/users/jakearchibald/orgs","repos_url":"https://api.github.com/users/jakearchibald/repos","events_url":"https://api.github.com/users/jakearchibald/events{/privacy}","received_events_url":"https://api.github.com/users/jakearchibald/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/w3c/ServiceWorker/milestones/3","html_url":"https://github.com/w3c/ServiceWorker/milestones/Version%202","labels_url":"https://api.github.com/repos/w3c/ServiceWorker/milestones/3/labels","id":825216,"number":3,"title":"Version 2","description":null,"creator":{"login":"KenjiBaheux","id":6354698,"avatar_url":"https://avatars.githubusercontent.com/u/6354698?v=3","gravatar_id":"","url":"https://api.github.com/users/KenjiBaheux","html_url":"https://github.com/KenjiBaheux","followers_url":"https://api.github.com/users/KenjiBaheux/followers","following_url":"https://api.github.com/users/KenjiBaheux/following{/other_user}","gists_url":"https://api.github.com/users/KenjiBaheux/gists{/gist_id}","starred_url":"https://api.github.com/users/KenjiBaheux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KenjiBaheux/subscriptions","organizations_url":"https://api.github.com/users/KenjiBaheux/orgs","repos_url":"https://api.github.com/users/KenjiBaheux/repos","events_url":"https://api.github.com/users/KenjiBaheux/events{/privacy}","received_events_url":"https://api.github.com/users/KenjiBaheux/received_events","type":"User","site_admin":false},"open_issues":47,"closed_issues":29,"state":"open","created_at":"2014-10-14T08:25:32Z","updated_at":"2016-08-25T19:17:34Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-10-28T07:53:49Z","updated_at":"2016-10-03T13:38:14Z","closed_at":null,"body":"To wait for the current registration to get an active worker. This helps explain `navigator.serviceWorker.ready`"},"comment":{"url":"https://api.github.com/repos/w3c/ServiceWorker/issues/comments/251107543","html_url":"https://github.com/w3c/ServiceWorker/issues/770#issuecomment-251107543","issue_url":"https://api.github.com/repos/w3c/ServiceWorker/issues/770","id":251107543,"user":{"login":"jakearchibald","id":93594,"avatar_url":"https://avatars.githubusercontent.com/u/93594?v=3","gravatar_id":"","url":"https://api.github.com/users/jakearchibald","html_url":"https://github.com/jakearchibald","followers_url":"https://api.github.com/users/jakearchibald/followers","following_url":"https://api.github.com/users/jakearchibald/following{/other_user}","gists_url":"https://api.github.com/users/jakearchibald/gists{/gist_id}","starred_url":"https://api.github.com/users/jakearchibald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakearchibald/subscriptions","organizations_url":"https://api.github.com/users/jakearchibald/orgs","repos_url":"https://api.github.com/users/jakearchibald/repos","events_url":"https://api.github.com/users/jakearchibald/events{/privacy}","received_events_url":"https://api.github.com/users/jakearchibald/received_events","type":"User","site_admin":false},"created_at":"2016-10-03T13:38:14Z","updated_at":"2016-10-03T13:38:14Z","body":"Here's a rough polyfill for those looking for one:\r\n\r\n```js\r\nfunction regReady(reg) {\r\n  return new Promise((resolve, reject) => {\r\n    if (reg.active) {\r\n      resolve();\r\n      return;\r\n    }\r\n\r\n    if (!reg.installing && !reg.waiting) {\r\n      reject(Error('Install failed'));\r\n      return;\r\n    }\r\n\r\n    (reg.installing || reg.waiting).addEventListener('statechange', function() {\r\n      if (this.state == 'redundant') {\r\n        reject(Error('Install failed'));\r\n      } else if (this.state == 'activated') {\r\n        resolve();\r\n      }\r\n    });\r\n  });\r\n}\r\n```"}}
{"actor":{"display_login":"jakearchibald"}}