feat(service-worker): Add typing for messagesClicked in SwPush service (#25860)
- Properly type messagesClicked Observable stream - Add new NotificationObject interface PR Close #25860
This commit is contained in:
parent
1aca54da06
commit
c78c221028
|
@ -52,6 +52,10 @@ interface StatusEvent {
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface NotificationObject extends NotificationOptions {
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function errorObservable(message: string): Observable<any> {
|
function errorObservable(message: string): Observable<any> {
|
||||||
return defer(() => throwError(new Error(message)));
|
return defer(() => throwError(new Error(message)));
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {Injectable} from '@angular/core';
|
||||||
import {NEVER, Observable, Subject, merge} from 'rxjs';
|
import {NEVER, Observable, Subject, merge} from 'rxjs';
|
||||||
import {map, switchMap, take} from 'rxjs/operators';
|
import {map, switchMap, take} from 'rxjs/operators';
|
||||||
|
|
||||||
import {ERR_SW_NOT_SUPPORTED, NgswCommChannel, PushEvent} from './low_level';
|
import {ERR_SW_NOT_SUPPORTED, NgswCommChannel, NotificationObject, PushEvent} from './low_level';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,21 @@ export class SwPush {
|
||||||
*/
|
*/
|
||||||
readonly messages: Observable<object>;
|
readonly messages: Observable<object>;
|
||||||
|
|
||||||
readonly messagesClicked: Observable<object>;
|
/**
|
||||||
|
* Emits the payloads of the received push notification messages as well as the action the user
|
||||||
|
* 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
|
||||||
|
* [NotificationOptions](https://notifications.spec.whatwg.org/#dictdef-notificationoptions)
|
||||||
|
* object that also includes the notification `title`.
|
||||||
|
*/
|
||||||
|
readonly messagesClicked: Observable < {
|
||||||
|
action: string;
|
||||||
|
notification: NotificationObject
|
||||||
|
}
|
||||||
|
> ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits the currently active
|
* Emits the currently active
|
||||||
|
|
Loading…
Reference in New Issue