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

Thanks Joshua, I'm going for this: -

`
        var  ioResolve, ioReject;

 var  pong  = 
   new Promise(function(res, rej){
       ioResolve = res;
       ioReject  = rej;
      });

 event.respondWith(pong);
 console.log("After respondWith()");

    function reply(result){
        console.log("In reply", replied, result);
        if (replied) return;
  
  ioResolve.call(null, result);
        console.log("After reply", replied);

        replied = true;
    }
`

I'm debugging in it now but I've had to go back to my Promises 101 notes because this is driving me nuts: -

`    var inBuff =
        new Promise(
            function(resolve,reject){               
                caches.match(event.request.clone())
                      .then(response => {
        console.log("*"+response+"*");
        if (response == undefined) console.log("yes sir");
                          reject(new Error("Not Found"));        
       })
            }
        ).catch((error)=>{console.log("nomatch" + error)});
` 

Even though there's no match in the cache and all the correct logging occurs and reject() has been called, later, when I try inBuff.then() the THEN happens rather than the ELSE. The debugger says inBuff is in state "resolved" with an undefined value. I'll sort it out.

BTW. Kids are good, thanks for asking. Linda Blair's head stopped spinning and the boy only had one dry reach after the first race and that was through effort.

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

Received on Saturday, 12 March 2016 11:57:30 UTC