[slightlyoff/ServiceWorker] Provide a convenience method to run code outside event handler (#866)

If you want to do something like respond to a fetch event ASAP, but kick off some background work like an update check, you don't have a direct way to do that without running code outside a SW event handler (which appears to be disallowed).

I think the workaround is to post a message to a client, which then posts back, and then you do the work in the message handler. This seems unnecessarily bureaucratic and is quite a problem if there isn't actually a client available (particularly noting that there does not appear to be a client available in the "navigate" fetch request).

So why not provide something like a `self.run(promise)` method that provides a way for a SW to run more code without risking it being terminated?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/866

Received on Wednesday, 6 April 2016 10:50:16 UTC