- From: Richard Maher <notifications@github.com>
- Date: Tue, 23 Feb 2016 22:41:30 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Message-ID: <slightlyoff/ServiceWorker/issues/838/188104661@github.com>
Not sure about Ben's definition of "Safely" and I hope this is a half relevant and intelligent question.
WRT: - https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#extendable-event-waituntil-method
> Do not terminate the service worker whose responsible event loop is running task until waiting for all of extendLifetimePromises settles.
Is it be possible that @mkruisselbrink could wrap his setTimeout up in a promise like: -
function wait(time) {
return new Promise(function(resolve, reject) {
var req = setTimeout(function(){resolve();}, time);
});
}
wait(5000).then(function(resp){alert('Finished waiting');},function(err){});
. . . and such an action (***logically*** in-lining the wait) would mark the SW as immune from "idle" termination?
Then @mkruisselbrink could do a Promise.race([fromWait, fromFetch]);
function myFunction() {
var p1 = wait(5000);
var pa = [p1];
Promise.race(pa).then(function(resp){
alert('Finished waiting');
},
function(err){});
}
---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/838#issuecomment-188104661
Received on Wednesday, 24 February 2016 06:42:03 UTC