docs(aio): Rename service worker files, update examples, move service worker under Techniques

This commit is contained in:
chembu
2017-12-06 18:12:19 -08:00
committed by Alex Rickabaugh
parent 8458647232
commit f593552cfe
27 changed files with 198 additions and 75 deletions

View File

@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import { SwUpdate } from '@angular/service-worker';
function promptUser(event): boolean {
return true;
}
// #docregion sw-activate
@Injectable()
export class PromptUpdateService {
constructor(updates: SwUpdate) {
updates.available.subscribe(event => {
if (promptUser(event)) {
updates.activateUpdate().then(() => document.location.reload());
}
});
}
}
// #enddocregion sw-activate