Skip to content

Commit b99f22a

Browse files
committed
refactor(db): run fromRef in a zone
1 parent f41db2b commit b99f22a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "angularfire2",
3-
"version": "4.0.0-rc.3-exp.2",
3+
"version": "4.0.0-rc.3-exp.6",
44
"description": "The official library of Firebase and Angular.",
55
"private": true,
66
"scripts": {
7-
"test": "karma start --single-run",
7+
"test": "npm run build && karma start --single-run",
88
"test:watch": "concurrently \"npm run build:watch\" \"npm run delayed_karma\"",
99
"test:debug": "npm run build && karma start",
1010
"delayed_karma": "sleep 10 && karma start",

src/database/database.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export {
4141
SnapshotChange,
4242
QueryFn,
4343
ListReference,
44-
ObjectReference
44+
ObjectReference,
45+
AngularFireAction,
46+
Action,
47+
SnapshotAction
4548
} from './interfaces';
4649

src/database/observable/fromRef.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { DatabaseQuery, DatabaseSnapshot, ListenEvent, SnapshotPrevKey, AngularFireAction } from '../interfaces';
22
import { Observable } from 'rxjs/Observable';
3+
import { observeOn } from 'rxjs/operator/observeOn';
4+
import { ZoneScheduler } from 'angularfire2';
35
import 'rxjs/add/operator/map';
46
import 'rxjs/add/operator/delay';
57

@@ -9,7 +11,7 @@ import 'rxjs/add/operator/delay';
911
* @param event Listen event type ('value', 'added', 'changed', 'removed', 'moved')
1012
*/
1113
export function fromRef(ref: DatabaseQuery, event: ListenEvent, listenType = 'on'): Observable<AngularFireAction<DatabaseSnapshot | null>> {
12-
return new Observable<SnapshotPrevKey | null | undefined>(subscriber => {
14+
const ref$ = new Observable<SnapshotPrevKey | null | undefined>(subscriber => {
1315
const fn = ref[listenType](event, (snapshot, prevKey) => {
1416
subscriber.next({ snapshot, prevKey })
1517
}, subscriber.error.bind(subscriber));
@@ -25,4 +27,5 @@ export function fromRef(ref: DatabaseQuery, event: ListenEvent, listenType = 'on
2527
// a quirk in the SDK where on/once callbacks can happen
2628
// synchronously.
2729
.delay(0);
30+
return observeOn.call(ref$, new ZoneScheduler(Zone.current));
2831
}

0 commit comments

Comments
 (0)