@@ -33,13 +33,11 @@ import { FirebaseDatabase } from '@firebase/database-types';
33
33
* @implements {FirebaseService}
34
34
*/
35
35
export class Database implements FirebaseService {
36
- INTERNAL : DatabaseInternals ;
37
-
38
36
/** Track if the instance has been used (root or repo accessed) */
39
37
private instanceStarted_ : boolean = false ;
40
38
41
39
/** Backing state for root_ */
42
- private rootInternal_ : Reference ;
40
+ private rootInternal_ ? : Reference ;
43
41
44
42
static readonly ServerValue = {
45
43
TIMESTAMP : {
@@ -64,20 +62,22 @@ export class Database implements FirebaseService {
64
62
"Don't call new Database() directly - please use firebase.database()."
65
63
) ;
66
64
}
67
-
68
- this . repo_ = repoInternal_ ;
69
- this . INTERNAL = new DatabaseInternals ( this ) ;
70
65
}
71
66
67
+ INTERNAL = {
68
+ delete : async ( ) => {
69
+ this . checkDeleted_ ( 'delete' ) ;
70
+ RepoManager . getInstance ( ) . deleteRepo ( this . repo_ ) ;
71
+ this . repoInternal_ = null ;
72
+ this . rootInternal_ = null ;
73
+ }
74
+ } ;
75
+
72
76
private get repo_ ( ) : Repo {
73
77
this . instanceStarted_ = true ;
74
78
return this . repoInternal_ ;
75
79
}
76
80
77
- private set repo_ ( repo : Repo ) {
78
- this . repoInternal_ = repo ;
79
- }
80
-
81
81
get root_ ( ) : Reference {
82
82
if ( ! this . rootInternal_ ) {
83
83
this . rootInternal_ = new Reference ( this . repo_ , Path . Empty ) ;
@@ -86,10 +86,6 @@ export class Database implements FirebaseService {
86
86
return this . rootInternal_ ;
87
87
}
88
88
89
- set root_ ( root : Reference ) {
90
- this . rootInternal_ = root ;
91
- }
92
-
93
89
get app ( ) : FirebaseApp {
94
90
return this . repo_ . app ;
95
91
}
@@ -111,7 +107,11 @@ export class Database implements FirebaseService {
111
107
}
112
108
113
109
// Modify the repo to apply emulator settings
114
- RepoManager . getInstance ( ) . applyEmulatorSettings ( this . repoInternal_ , host , port ) ;
110
+ RepoManager . getInstance ( ) . applyEmulatorSettings (
111
+ this . repoInternal_ ,
112
+ host ,
113
+ port
114
+ ) ;
115
115
}
116
116
117
117
/**
@@ -190,22 +190,3 @@ export class Database implements FirebaseService {
190
190
this . repo_ . resume ( ) ;
191
191
}
192
192
}
193
-
194
- export class DatabaseInternals {
195
- /** @param {!Database } database */
196
- constructor ( public database : Database ) { }
197
-
198
- /** @return {Promise<void> } */
199
- async delete ( ) : Promise < void > {
200
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
- ( this . database as any ) . checkDeleted_ ( 'delete' ) ;
202
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
- RepoManager . getInstance ( ) . deleteRepo ( ( this . database as any ) . repo_ as Repo ) ;
204
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
205
- ( this . database as any ) . repo_ = null ;
206
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
207
- ( this . database as any ) . root_ = null ;
208
- this . database . INTERNAL = null ;
209
- this . database = null ;
210
- }
211
- }
0 commit comments