Skip to content

Commit 9da8911

Browse files
committed
refactor: move InjectionTokenType & zoneOptimized to @ng-web-apis/common
1 parent fb4d9ab commit 9da8911

File tree

5 files changed

+4
-10
lines changed

5 files changed

+4
-10
lines changed

libs/common/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ export * from './tokens/speech-recognition';
1717
export * from './tokens/speech-synthesis';
1818
export * from './tokens/user-agent';
1919
export * from './tokens/window';
20+
export * from './types/injection-token-type';
21+
export * from './utils/zone';
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
import type {InjectionToken} from '@angular/core';
22

3-
// TODO: discuss with team what should we do with this code duplication
4-
// Could we use `@taiga-ui/cdk` inside `@ng-web-apis/notification` ?
5-
63
export type InjectionTokenType<Token> = Token extends InjectionToken<infer T> ? T : never;

libs/notification/src/utils/zone.ts renamed to libs/common/src/utils/zone.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import {NgZone} from '@angular/core';
22
import {MonoTypeOperatorFunction, Observable, pipe} from 'rxjs';
33

4-
// TODO: discuss with team what should we do with this code duplication
5-
// Could we use `@taiga-ui/cdk` inside `@ng-web-apis/notification` ?
6-
74
export function zonefree<T>(zone: NgZone): MonoTypeOperatorFunction<T> {
85
return source =>
96
new Observable(subscriber =>

libs/notification/src/services/notification.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Inject, Injectable} from '@angular/core';
2-
import {SERVICE_WORKER} from '@ng-web-apis/common';
2+
import {InjectionTokenType, SERVICE_WORKER} from '@ng-web-apis/common';
33
import {
44
filter,
55
from,
@@ -17,7 +17,6 @@ import {NOTIFICATION_SW_CLICKS} from '../tokens/notification-clicks';
1717
import {NOTIFICATION_SW_CLOSES} from '../tokens/notification-closes';
1818
import {NOTIFICATION_FACTORY} from '../tokens/notification-factory';
1919
import {NOTIFICATION_SUPPORT} from '../tokens/support';
20-
import {InjectionTokenType} from '../types/injection-token-type';
2120

2221
const NOT_SUPPORTED_ERROR$ = throwError(
2322
() => new Error('Notification API is not supported in your browser'),

libs/notification/src/tokens/notification-closes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {inject, InjectionToken, NgZone} from '@angular/core';
2-
import {ANIMATION_FRAME, SERVICE_WORKER} from '@ng-web-apis/common';
2+
import {ANIMATION_FRAME, SERVICE_WORKER, zoneOptimized} from '@ng-web-apis/common';
33
import {
44
combineLatest,
55
filter,
@@ -11,7 +11,6 @@ import {
1111
share,
1212
switchMap,
1313
} from 'rxjs';
14-
import {zoneOptimized} from '../utils/zone';
1514

1615
export const NOTIFICATION_SW_CLOSES = new InjectionToken(
1716
`Global listener for events when ANY system notification spawned by Notification API (and only inside Service Worker!) has been closed`,

0 commit comments

Comments
 (0)