docs(service-worker): add section to explain unrecoverable state (#36847)

PR Close #36847
This commit is contained in:
Sonu Kapoor
2020-08-02 19:31:01 -04:00
committed by Joey Perrott
parent 036a2faf02
commit f5d1e9a2d1
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { Injectable } from '@angular/core';
import { SwUpdate } from '@angular/service-worker';
function notifyUser(message: string): void { }
// #docregion sw-unrecoverable-state
@Injectable()
export class HandleUnrecoverableStateService {
constructor(updates: SwUpdate) {
updates.unrecoverable.subscribe(event => {
notifyUser(
`An error occurred that we cannot recover from:\n${event.reason}\n\n` +
'Please reload the page.');
});
}
}
// #enddocregion sw-unrecoverable-state