- From: Jake Archibald <notifications@github.com>
- Date: Mon, 22 Feb 2016 08:06:11 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Monday, 22 February 2016 16:07:06 UTC
Agree this should be middleware, since it might be a series or a race depending on the app, and you may not want to run additional handlers until others fail to provide a response. ```js const handlers = []; self.addEventListener('fetch', event => { event.respondWith(async function() { for (const handler of handers) { const response = await handler(event.request); if (response) return response; } return fetch(event.request); }()); }); handlers.push(request => { // … }); handlers.push(request => { // … }); handlers.push(request => { // … }); ``` --- Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/836#issuecomment-187246291
Received on Monday, 22 February 2016 16:07:06 UTC