Skip to content

Commit 43fffee

Browse files
committed
App field
1 parent d676026 commit 43fffee

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

packages/messaging-types/index.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import {
2424
CompleteFn
2525
} from '@firebase/util';
2626

27-
export class FirebaseMessaging {
28-
private constructor(app: FirebaseApp);
29-
readonly app: FirebaseApp;
27+
export interface FirebaseMessaging {
3028
// TODO: remove the token parameter and just delete the token that matches
3129
// this app if it exists.
3230
deleteToken(token: string): Promise<boolean>;

packages/messaging/src/controllers/sw-controller.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,17 @@ import { Unsubscribe } from '@firebase/util';
3030
import { sleep } from '../helpers/sleep';
3131
import { FirebaseApp } from '@firebase/app-types';
3232
import { isConsoleMessage } from '../helpers/is-console-message';
33+
import { FirebaseService } from '@firebase/app-types/private';
3334

3435
// Let TS know that this is a service worker
3536
declare const self: ServiceWorkerGlobalScope;
3637

3738
export type BgMessageHandler = (payload: MessagePayload) => unknown;
3839

39-
export class SwController implements FirebaseMessaging {
40+
export class SwController implements FirebaseMessaging, FirebaseService {
4041
private vapidKey: string | null = null;
4142
private bgMessageHandler: BgMessageHandler | null = null;
4243

43-
get app(): FirebaseApp {
44-
return this.firebaseDependencies.app;
45-
}
46-
4744
constructor(
4845
private readonly firebaseDependencies: FirebaseInternalDependencies
4946
) {
@@ -58,6 +55,10 @@ export class SwController implements FirebaseMessaging {
5855
});
5956
}
6057

58+
get app(): FirebaseApp {
59+
return this.firebaseDependencies.app;
60+
}
61+
6162
/**
6263
* Calling setBackgroundMessageHandler will opt in to some specific
6364
* behaviours.

packages/messaging/src/controllers/window-controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ import {
3333
import { FirebaseApp } from '@firebase/app-types';
3434
import { ConsoleMessageData } from '../interfaces/message-payload';
3535
import { isConsoleMessage } from '../helpers/is-console-message';
36+
import { FirebaseService } from '@firebase/app-types/private';
3637

37-
export class WindowController implements FirebaseMessaging {
38+
export class WindowController implements FirebaseMessaging, FirebaseService {
3839
private vapidKey: string | null = null;
3940
private swRegistration?: ServiceWorkerRegistration;
4041
private onMessageCallback: NextFn<object> | null = null;

packages/messaging/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
import firebase from '@firebase/app';
1919
import '@firebase/installations';
20-
import { _FirebaseNamespace } from '@firebase/app-types/private';
20+
import {
21+
_FirebaseNamespace,
22+
FirebaseService
23+
} from '@firebase/app-types/private';
2124
import { FirebaseMessaging } from '@firebase/messaging-types';
2225
import {
2326
Component,
@@ -31,7 +34,9 @@ import { WindowController } from './controllers/window-controller';
3134
import { SwController } from './controllers/sw-controller';
3235

3336
const MESSAGING_NAME = 'messaging';
34-
function factoryMethod(container: ComponentContainer): FirebaseMessaging {
37+
function factoryMethod(
38+
container: ComponentContainer
39+
): FirebaseService & FirebaseMessaging {
3540
// Dependencies.
3641
const app = container.getProvider('app').getImmediate();
3742
const appConfig = extractAppConfig(app);

0 commit comments

Comments
 (0)