fix(service-worker): Fix public api guard typing (#25860)

PR Close #25860
This commit is contained in:
Joost Zöllner
2018-09-28 10:28:53 +02:00
committed by Kara Erickson
parent 10618752e6
commit 4a01ada291
8 changed files with 29 additions and 29 deletions

View File

@ -52,8 +52,6 @@ interface StatusEvent {
error?: string;
}
export interface NotificationObject extends NotificationOptions { title: string; }
function errorObservable(message: string): Observable<any> {
return defer(() => throwError(new Error(message)));

View File

@ -10,7 +10,7 @@ import {Injectable} from '@angular/core';
import {NEVER, Observable, Subject, merge} from 'rxjs';
import {map, switchMap, take} from 'rxjs/operators';
import {ERR_SW_NOT_SUPPORTED, NgswCommChannel, NotificationObject, PushEvent} from './low_level';
import {ERR_SW_NOT_SUPPORTED, NgswCommChannel, PushEvent} from './low_level';
/**
@ -30,14 +30,16 @@ export class SwPush {
* interacted with.
* If no action was used the action property will be an empty string `''`.
*
* Note that the `notification` property is __not__ a
* [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification) but rather a
* Note that the `notification` property is **not** a
* [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification) object but rather
* a
* [NotificationOptions](https://notifications.spec.whatwg.org/#dictdef-notificationoptions)
* object that also includes the notification `title`.
* object that also includes the `title` of the
* [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification) object.
*/
readonly messagesClicked: Observable < {
readonly notificationClicks: Observable < {
action: string;
notification: NotificationObject
notification: NotificationOptions&{ title: string }
}
> ;
@ -61,14 +63,14 @@ export class SwPush {
constructor(private sw: NgswCommChannel) {
if (!sw.isEnabled) {
this.messages = NEVER;
this.messagesClicked = NEVER;
this.notificationClicks = NEVER;
this.subscription = NEVER;
return;
}
this.messages = this.sw.eventsOfType<PushEvent>('PUSH').pipe(map(message => message.data));
this.messagesClicked =
this.notificationClicks =
this.sw.eventsOfType('NOTIFICATION_CLICK').pipe(map((message: any) => message.data));
this.pushManager = this.sw.registration.pipe(map(registration => registration.pushManager));