From d7887ab4abf9b7610ad172dc00f2ff5eab08b710 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Thu, 25 Apr 2019 16:51:07 +0300 Subject: [PATCH] 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 --- packages/service-worker/src/module.ts | 12 ++++++------ packages/service-worker/test/comm_spec.ts | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/service-worker/src/module.ts b/packages/service-worker/src/module.ts index 4cc7bc3f69..3d324bc37d 100644 --- a/packages/service-worker/src/module.ts +++ b/packages/service-worker/src/module.ts @@ -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('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); @@ -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, }, ], diff --git a/packages/service-worker/test/comm_spec.ts b/packages/service-worker/test/comm_spec.ts index 714e9ba79d..09b9af248e 100644 --- a/packages/service-worker/test/comm_spec.ts +++ b/packages/service-worker/test/comm_spec.ts @@ -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] } ] });