Message from JavaScript discussions

July 2019

— `this.addEventListener('fetch', function (event) {
console.log('fetching ->', event.request);
event.respondWith(
caches.match(event.request)
.then(function (resp) {
return resp || fetch(event.request)
.then(function (response) {
caches.open('v1')
.then(function (cache) {
cache.put(event.request, response.clone());
});
return response;
});
})
);
})`

Message permanent page

— 

I think i havent understand the arrow functions quite yet in js. Whats wrong here ?



const getComputerWeapon = Math.floor(Math.random() *3) => {

— Wat

— The start of an arrow function should be an argument list

— Not an expression

— Oh

— And if i have no arguments then i just put a () into it ?

— Yep

— Ahhhhh :D Thanks now i got it

— So as far as im concerned, a webworker wont really outsource the fetch in another thread but is prett y much just a proxy, and therefore better for computing stuff? still useful to me, but still not sure if im getting this right. any thoughts on this?

Message permanent page

— Btw im not trying to build a pwa

— Just imporoving on performance