Skip to content

Commit

Permalink
fix(database): fix Zone.js issues by running ref-gen outside angular
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdaniels committed Nov 18, 2020
1 parent f8830d1 commit 5186389
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion sample/src/app/database/database.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class DatabaseComponent implements OnInit {
public readonly testObjectValue$: Observable<any>;

constructor(state: TransferState, database: AngularFireDatabase, @Inject(PLATFORM_ID) platformId: object) {
// TODO fix the Zone.js issue with AngularFireDatabase
if (isPlatformServer(platformId)) {
this.testObjectValue$ = EMPTY;
} else {
Expand Down
2 changes: 1 addition & 1 deletion sample/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FirebaseApp } from '@angular/fire';
template: `
Hello world!
{{ firebaseApp.name }}
<!-- TODO wrap the Zone issue <app-database></app-database> -->
<app-database></app-database>
<app-firestore></app-firestore>
<app-firestore-offline></app-firestore-offline>
<app-storage></app-storage>
Expand Down
7 changes: 4 additions & 3 deletions src/database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class AngularFireDatabase {
}

list<T>(pathOrRef: PathReference, queryFn?: QueryFn): AngularFireList<T> {
const ref = getRef(this.database, pathOrRef);
const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));
let query: DatabaseQuery = ref;
if (queryFn) {
query = queryFn(ref);
Expand All @@ -74,12 +74,13 @@ export class AngularFireDatabase {
}

object<T>(pathOrRef: PathReference): AngularFireObject<T> {
const ref = getRef(this.database, pathOrRef);
const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));
return createObjectReference<T>(ref, this);
}

createPushId() {
return this.database.ref().push().key;
const ref = this.schedulers.ngZone.runOutsideAngular(() => this.database.ref());
return ref.push().key;
}

}
Expand Down

0 comments on commit 5186389

Please sign in to comment.