yyx990803 / register-service-worker

A script to simplify service worker registration with hooks for common events.
MIT License
638 stars 58 forks source link

Why is emit undefined in unregister #62

Closed kopax-polyconseil closed 2 years ago

kopax-polyconseil commented 2 years ago

Hi @yyx990803 and thanks for sharing. I am reading at your code and I try to understand why this is not defined in the function scope : https://github.com/yyx990803/register-service-worker/blob/756fe7fe956b092b0afc86d55a3fd24f181f4da7/src/index.js#L127

Thanks in advance,

seyfer commented 2 years ago

@yyx990803 please also add SW cache removal to unregister function

// Delete SW Cache
if ('caches' in window) {
    caches.keys()
      .then(function(keyList) {
          return Promise.all(keyList.map(function(key) {
              return caches.delete(key);
          }));
      })
}