Re: [ServiceWorker] Fetch API respondWith's implicit RETURN (#844)

Sorry, I've one child throwing up all night and another going to rowing in 25 mins so not 100% on the latest, but back on the "before the callback returns" (Jake's example http://jsbin.com/wowevi/edit?js,console )

If I can use a promise like this: -

function wait(ms) {
  return new Promise(resolve => {
    setTimeout(resolve, ms);
  });
}

Then surely: - wait(22).then(console.log(***'this is not called within the callback'***) ?

You bypassed promises with their logical in-lining and went to back to straight Events so I just want to clear up if your "within the callback" context is effected?

> This flag is set after dispatch (18.5), so if it isn't called by then, it's ignored.

Wow, thanks for the reference and I stand corrected. (.20 seemed to be definitive)

So later today I'll : -

1) New-up a new promise immediately in the FetchEvent
2) Call fetchEvent.respondWith(myNewPromise)
3) In my reply function, instead of calling respondWith I'll call myPromise.resolve()

Would that be kosher now? Is my use of the waitUntil appropriate or is the repondWithEntered flag now achieving the same thing for me?



---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/844#issuecomment-195543842

Received on Friday, 11 March 2016 20:44:30 UTC