-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notification): add service worker support for `@ng-web-apis/noti…
…fication`
- Loading branch information
1 parent
83fd5c7
commit b16edfa
Showing
19 changed files
with
262 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
apps/demo/src/app/pages/notification/examples/02-create-notification/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apps/demo/src/app/pages/notification/examples/03-close-notification/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {inject, InjectionToken} from '@angular/core'; | ||
import {NAVIGATOR} from './navigator'; | ||
|
||
export const SERVICE_WORKER = new InjectionToken( | ||
`An abstraction over window.navigator.serviceWorker object`, | ||
{ | ||
factory: () => inject(NAVIGATOR).serviceWorker, | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type {InjectionToken} from '@angular/core'; | ||
|
||
export type InjectionTokenType<Token> = Token extends InjectionToken<infer T> ? T : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {NgZone} from '@angular/core'; | ||
import {MonoTypeOperatorFunction, Observable, pipe} from 'rxjs'; | ||
|
||
export function zonefree<T>(zone: NgZone): MonoTypeOperatorFunction<T> { | ||
return source => | ||
new Observable(subscriber => | ||
zone.runOutsideAngular(() => source.subscribe(subscriber)), | ||
); | ||
} | ||
|
||
export function zonefull<T>(zone: NgZone): MonoTypeOperatorFunction<T> { | ||
return source => | ||
new Observable(subscriber => | ||
source.subscribe({ | ||
next: value => zone.run(() => subscriber.next(value)), | ||
error: (error: unknown) => zone.run(() => subscriber.error(error)), | ||
complete: () => zone.run(() => subscriber.complete()), | ||
}), | ||
); | ||
} | ||
|
||
export function zoneOptimized<T>(zone: NgZone): MonoTypeOperatorFunction<T> { | ||
return pipe(zonefree(zone), zonefull(zone)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './services/notification.service'; | ||
export * from './tokens/notification-factory'; | ||
export * from './tokens/support'; | ||
export * from './utils/provide-sw-push'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {InjectionToken} from '@angular/core'; | ||
import type {SwPush} from '@angular/service-worker'; | ||
import {NEVER} from 'rxjs'; | ||
|
||
export const NOTIFICATION_SW_CLICKS = new InjectionToken<SwPush['notificationClicks']>( | ||
`Global listener for events when ANY system notification spawned by Notification API (and only inside Service Worker!) has been clicked`, | ||
{ | ||
factory: () => NEVER, | ||
}, | ||
); |
Oops, something went wrong.