docs(service-worker): improve SwRegistrationOptions docs and add example (#21842)

PR Close #21842
This commit is contained in:
George Kalpakas
2019-04-25 16:51:08 +03:00
committed by Andrew Kushnir
parent be28a6ad8e
commit aa53d6cc6d
8 changed files with 201 additions and 2 deletions

View File

@ -18,11 +18,29 @@ import {SwUpdate} from './update';
* Token that can be used to provide options for `ServiceWorkerModule` outside of
* `ServiceWorkerModule.register()`.
*
* You can use this token to define a provider that generates the registration options at runtime,
* for example via a function call:
*
* {@example service-worker/registration-options/module.ts region="registration-options"
* header="app.module.ts" linenums="false"}
*
* @publicApi
*/
export abstract class SwRegistrationOptions {
scope?: string;
/**
* Whether the ServiceWorker will be registered and the related services (such as `SwPush` and
* `SwUpdate`) will attempt to communicate and interact with it.
*
* Default: true
*/
enabled?: boolean;
/**
* A URL that defines the ServiceWorker's registration scope; that is, what range of URLs it can
* control. It will be used when calling
* [ServiceWorkerContainer#register()](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register).
*/
scope?: string;
}
export const SCRIPT = new InjectionToken<string>('NGSW_REGISTER_SCRIPT');