Skip to content

Commit 3b95509

Browse files
committed
WIP: fixes after rebasing
1 parent 15fca6d commit 3b95509

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/database/api/Database.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Reference } from './Reference';
66
import { Repo } from '../core/Repo';
77
import { RepoManager } from '../core/RepoManager';
88
import { validateArgCount } from '../../utils/validation';
9-
import { FirebaseApp } from "../../app/firebase_app";
109
import { validateUrl } from '../core/util/validation';
1110
import { FirebaseApp, FirebaseService } from '../../app/firebase_app';
1211
import { RepoInfo } from '../core/RepoInfo';
@@ -16,13 +15,9 @@ import { RepoInfo } from '../core/RepoInfo';
1615
* @implements {FirebaseService}
1716
*/
1817
export class Database implements FirebaseService {
19-
/** @type {Reference} */
20-
private root_: Reference;
21-
22-
/** @type {DatabaseInternals} */
2318
INTERNAL: DatabaseInternals;
2419

25-
app: FirebaseApp | null;
20+
private root_: Reference;
2621

2722
static readonly ServerValue = {
2823
'TIMESTAMP': {
@@ -45,6 +40,10 @@ export class Database implements FirebaseService {
4540
this.INTERNAL = new DatabaseInternals(this);
4641
}
4742

43+
get app(): FirebaseApp {
44+
return this.repo_.app;
45+
}
46+
4847
/**
4948
* Returns a reference to the root or the path specified in opt_pathString.
5049
* @param {string=} pathString
@@ -105,8 +104,7 @@ export class Database implements FirebaseService {
105104
}
106105
}
107106

108-
class DatabaseInternals {
109-
database
107+
export class DatabaseInternals {
110108
/** @param {!Database} database */
111109
constructor(public database: Database) {
112110
}

src/database/core/Repo.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ const INTERRUPT_REASON = 'repo_interrupt';
3434
* A connection to a single data repository.
3535
*/
3636
export class Repo {
37-
/** @type {!Database} */
38-
database: Database;
3937
dataUpdateCount = 0;
4038
private infoSyncTree_: SyncTree;
4139
private serverSyncTree_: SyncTree;
@@ -51,6 +49,7 @@ export class Repo {
5149
private abortTransactions_: (path: Path) => Path;
5250
private rerunTransactions_: (changedPath: Path) => Path;
5351
private interceptServerDataCallback_: ((a: string, b: any) => void) | null = null;
52+
private __database: Database;
5453

5554
// A list of data pieces and paths to be set when this client disconnects.
5655
private onDisconnect_ = new SparseSnapshotTree();
@@ -552,5 +551,9 @@ export class Repo {
552551
});
553552
}
554553
}
554+
555+
get database(): Database {
556+
return this.__database || (this.__database = new Database(this));
557+
}
555558
}
556559

0 commit comments

Comments
 (0)