Created
March 6, 2017 22:15
-
-
Save gauntface/5a4ad9e589d46718fe0a5e44203fcf3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return new Promise((resolve, reject) => { | |
| const event = new FetchEvent('fetch', { | |
| request: new Request('/index.html'), | |
| }); | |
| event.respondWith = (promiseChain) => { | |
| if (promiseChain) { | |
| // Check if promise was returned - otherise | |
| // it could be a response | |
| if (promiseChain instanceof Promise) { | |
| promiseChain.then(resolve, reject); | |
| } else { | |
| resolve(promiseChain); | |
| } | |
| return; | |
| } | |
| resolve(); | |
| }; | |
| self.dispatchEvent(event); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment