refactor(service-worker): rename `RegistrationOptions` to `SwRegistrationOptions` (#21842)

This is in preparation of making `RegistrationOptions` part of the
public API (in a subsequent commit).

PR Close #21842
This commit is contained in:
George Kalpakas 2019-04-25 16:51:07 +03:00 committed by Andrew Kushnir
parent 2236ea4359
commit d7887ab4ab
2 changed files with 15 additions and 15 deletions

View File

@ -14,7 +14,7 @@ import {NgswCommChannel} from './low_level';
import {SwPush} from './push';
import {SwUpdate} from './update';
export abstract class RegistrationOptions {
export abstract class SwRegistrationOptions {
scope?: string;
enabled?: boolean;
}
@ -22,7 +22,7 @@ export abstract class RegistrationOptions {
export const SCRIPT = new InjectionToken<string>('NGSW_REGISTER_SCRIPT');
export function ngswAppInitializer(
injector: Injector, script: string, options: RegistrationOptions,
injector: Injector, script: string, options: SwRegistrationOptions,
platformId: string): Function {
const initializer = () => {
const app = injector.get<ApplicationRef>(ApplicationRef);
@ -50,7 +50,7 @@ export function ngswAppInitializer(
}
export function ngswCommChannelFactory(
opts: RegistrationOptions, platformId: string): NgswCommChannel {
opts: SwRegistrationOptions, platformId: string): NgswCommChannel {
return new NgswCommChannel(
isPlatformBrowser(platformId) && opts.enabled !== false ? navigator.serviceWorker :
undefined);
@ -75,16 +75,16 @@ export class ServiceWorkerModule {
ngModule: ServiceWorkerModule,
providers: [
{provide: SCRIPT, useValue: script},
{provide: RegistrationOptions, useValue: opts},
{provide: SwRegistrationOptions, useValue: opts},
{
provide: NgswCommChannel,
useFactory: ngswCommChannelFactory,
deps: [RegistrationOptions, PLATFORM_ID]
deps: [SwRegistrationOptions, PLATFORM_ID]
},
{
provide: APP_INITIALIZER,
useFactory: ngswAppInitializer,
deps: [Injector, SCRIPT, RegistrationOptions, PLATFORM_ID],
deps: [Injector, SCRIPT, SwRegistrationOptions, PLATFORM_ID],
multi: true,
},
],

View File

@ -9,7 +9,7 @@
import {PLATFORM_ID} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {NgswCommChannel} from '@angular/service-worker/src/low_level';
import {RegistrationOptions, ngswCommChannelFactory} from '@angular/service-worker/src/module';
import {SwRegistrationOptions, ngswCommChannelFactory} from '@angular/service-worker/src/module';
import {SwPush} from '@angular/service-worker/src/push';
import {SwUpdate} from '@angular/service-worker/src/update';
import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockServiceWorkerRegistration, patchDecodeBase64} from '@angular/service-worker/testing/mock';
@ -52,10 +52,10 @@ import {async_fit, async_it} from './async';
TestBed.configureTestingModule({
providers: [
{provide: PLATFORM_ID, useValue: 'server'},
{provide: RegistrationOptions, useValue: {enabled: true}}, {
{provide: SwRegistrationOptions, useValue: {enabled: true}}, {
provide: NgswCommChannel,
useFactory: ngswCommChannelFactory,
deps: [RegistrationOptions, PLATFORM_ID]
deps: [SwRegistrationOptions, PLATFORM_ID]
}
]
});
@ -66,10 +66,10 @@ import {async_fit, async_it} from './async';
TestBed.configureTestingModule({
providers: [
{provide: PLATFORM_ID, useValue: 'browser'},
{provide: RegistrationOptions, useValue: {enabled: false}}, {
{provide: SwRegistrationOptions, useValue: {enabled: false}}, {
provide: NgswCommChannel,
useFactory: ngswCommChannelFactory,
deps: [RegistrationOptions, PLATFORM_ID]
deps: [SwRegistrationOptions, PLATFORM_ID]
}
]
});
@ -80,11 +80,11 @@ import {async_fit, async_it} from './async';
TestBed.configureTestingModule({
providers: [
{provide: PLATFORM_ID, useValue: 'browser'},
{provide: RegistrationOptions, useValue: {enabled: true}},
{provide: SwRegistrationOptions, useValue: {enabled: true}},
{
provide: NgswCommChannel,
useFactory: ngswCommChannelFactory,
deps: [RegistrationOptions, PLATFORM_ID],
deps: [SwRegistrationOptions, PLATFORM_ID],
},
],
});
@ -110,10 +110,10 @@ import {async_fit, async_it} from './async';
TestBed.configureTestingModule({
providers: [
{provide: PLATFORM_ID, useValue: 'browser'},
{provide: RegistrationOptions, useValue: {enabled: true}}, {
{provide: SwRegistrationOptions, useValue: {enabled: true}}, {
provide: NgswCommChannel,
useFactory: ngswCommChannelFactory,
deps: [RegistrationOptions, PLATFORM_ID]
deps: [SwRegistrationOptions, PLATFORM_ID]
}
]
});