UNPKG

746 BJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8
9// tslint:disable:no-console
10
11self.addEventListener('install', event => {
12 self.skipWaiting();
13});
14
15self.addEventListener('activate', event => {
16 event.waitUntil(self.clients.claim());
17
18 event.waitUntil(self.registration.unregister().then(() => {
19 console.log('NGSW Safety Worker - unregistered old service worker');
20 }));
21
22 event.waitUntil(caches.keys().then(cacheNames => {
23 const ngswCacheNames = cacheNames.filter(name => /^ngsw:/.test(name));
24 return Promise.all(ngswCacheNames.map(name => caches.delete(name)));
25 }));
26});