Skip to content

Integrate with app-exp #3276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/firestore/exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface FirestoreDataConverter<T> {

export class FirebaseFirestore {
private constructor();
readonly app: FirebaseApp;
}

export function initializeFirestore(
Expand Down
1 change: 1 addition & 0 deletions packages/firestore/lite/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface FirestoreDataConverter<T> {

export class FirebaseFirestore {
private constructor();
readonly app: FirebaseApp;
}

export function initializeFirestore(
Expand Down
15 changes: 9 additions & 6 deletions packages/firestore/lite/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import * as firestore from '../../';

import { _getProvider } from '@firebase/app-exp';
import { FirebaseApp } from '@firebase/app-types-exp';
import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
import { Provider } from '@firebase/component';

import { Code, FirestoreError } from '../../../src/util/error';
Expand All @@ -42,12 +42,11 @@ import { Settings } from '../../';
const DEFAULT_HOST = 'firestore.googleapis.com';
const DEFAULT_SSL = true;

// TODO(firestorelite): Depend on FirebaseService once #3112 is merged

/**
* The root reference to the Firestore Lite database.
*/
export class Firestore implements firestore.FirebaseFirestore {
export class Firestore
implements firestore.FirebaseFirestore, _FirebaseService {
readonly _databaseId: DatabaseId;
private readonly _firebaseApp: FirebaseApp;
private readonly _credentials: CredentialsProvider;
Expand Down Expand Up @@ -120,6 +119,10 @@ export class Firestore implements firestore.FirebaseFirestore {

return new DatabaseId(app.options.projectId!);
}

delete(): Promise<void> {
return terminate(this);
}
}

export function initializeFirestore(
Expand All @@ -141,7 +144,7 @@ export function getFirestore(app: FirebaseApp): Firestore {
export function terminate(
firestore: firestore.FirebaseFirestore
): Promise<void> {
// TODO(firestorelite): Call _removeServiceInstance when available
_removeServiceInstance(firestore.app, 'firestore/lite');
const firestoreClient = cast(firestore, Firestore);
return firestoreClient
._getDatastore()
Expand Down