Skip to content

Commit d275a3e

Browse files
russellwheatleymikehardy
authored andcommitted
refactor(ml): align modular API with firebase-js-sdk
1 parent 90b73a2 commit d275a3e

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

packages/ml/lib/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*
1616
*/
1717

18-
export type { FirebaseML } from './types/ml';
18+
export * from './modular';
1919

20-
export type { FirebaseMLTypes } from './types/namespaced';
20+
export type { FirebaseApp, FirebaseML } from './types/ml';
2121

22-
export * from './modular';
22+
export type { FirebaseMLTypes } from './types/namespaced';
2323

2424
export * from './namespaced';
2525
export { default } from './namespaced';

packages/ml/lib/modular.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
*/
1717

1818
import { getApp } from '@react-native-firebase/app';
19-
import type { FirebaseApp } from '@react-native-firebase/app';
20-
import type { FirebaseML } from './types/ml';
19+
import type { FirebaseApp, FirebaseML } from './types/ml';
2120

2221
/**
23-
* Returns the existing default {@link FirebaseML} instance that is associated with the
24-
* default {@link @firebase/app!FirebaseApp}. If no instance exists, initializes a new
25-
* instance with default settings.
22+
* Returns the {@link FirebaseML} instance for the default or given {@link FirebaseApp}.
2623
*
27-
* @returns The {@link FirebaseML} instance of the provided app.
24+
* @param app - The Firebase `FirebaseApp` to use. When omitted, the default app is used.
25+
* @returns The ML service instance for that app.
2826
*/
2927
export function getML(app?: FirebaseApp): FirebaseML {
3028
if (app) {

packages/ml/lib/types/ml.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@
1515
*
1616
*/
1717

18-
import type { FirebaseApp } from '@react-native-firebase/app';
18+
import type { ReactNativeFirebase } from '@react-native-firebase/app';
19+
20+
export type FirebaseApp = ReactNativeFirebase.FirebaseApp;
1921

2022
/**
21-
* Firebase ML module instance for the modular API.
23+
* Firebase ML service instance for the modular API.
24+
*
25+
* Current Firebase JS SDK releases do not ship a `firebase/ml` modular entry point; this interface
26+
* follows the same modular service-instance pattern used elsewhere in React Native Firebase (see e.g.
27+
* the Firestore package's `Firestore` type).
2228
*/
23-
export interface FirebaseML {
29+
export interface FirebaseML extends ReactNativeFirebase.FirebaseModule {
2430
/** The FirebaseApp this module is associated with */
2531
app: FirebaseApp;
2632
}

0 commit comments

Comments
 (0)