mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat(aio): enable activating available ServiceWorker updates (#15561)
This commit is contained in:
committed by
Igor Minar
parent
67719f2185
commit
3ccbe28d9f
@@ -0,0 +1,4 @@
|
||||
export class MockSwUpdateNotificationsService {
|
||||
enable = jasmine.createSpy('MockSwUpdateNotificationsService.enable');
|
||||
disable = jasmine.createSpy('MockSwUpdateNotificationsService.disable');
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import 'rxjs/add/operator/distinctUntilChanged';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
|
||||
export class MockSwUpdatesService {
|
||||
$$activateUpdateSubj = new Subject<boolean>();
|
||||
$$isUpdateAvailableSubj = new Subject<boolean>();
|
||||
isUpdateAvailable = this.$$isUpdateAvailableSubj.distinctUntilChanged();
|
||||
|
||||
activateUpdate(): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
this.$$activateUpdateSubj
|
||||
// Better simulate what actually happens with the real ServiceWorker.
|
||||
.take(1)
|
||||
.do(() => this.$$isUpdateAvailableSubj.next(false))
|
||||
.subscribe(resolve);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user