diff --git a/src/database/query_observable.spec.ts b/src/database/query_observable.spec.ts index a2f0c4fd0..0ba11a27c 100644 --- a/src/database/query_observable.spec.ts +++ b/src/database/query_observable.spec.ts @@ -92,7 +92,6 @@ describe('observeQuery', () => { it('should omit only the orderBy type of the last emitted orderBy observable', () => { - // TODO: Should we allow re-emitting of the orderBy method? var nextSpy = jasmine.createSpy('next'); var query = { orderByKey: new Subject(), @@ -108,13 +107,19 @@ describe('observeQuery', () => { }); nextSpy.calls.reset(); query.orderByKey.next(true); - expect(nextSpy).not.toHaveBeenCalled(); - // nextSpy.calls.reset(); - // query.orderByValue.next(true); - // expect(nextSpy).toHaveBeenCalledWith({orderByValue: true}); - // nextSpy.calls.reset(); + expect(nextSpy).toHaveBeenCalledWith({ + orderByKey: true + }); + nextSpy.calls.reset(); + query.orderByValue.next(true); + expect(nextSpy).toHaveBeenCalledWith({ + orderByValue: true + }); + nextSpy.calls.reset(); query.orderByChild.next('foo'); - expect(nextSpy).toHaveBeenCalledWith({orderByChild: 'foo'}); + expect(nextSpy).toHaveBeenCalledWith({ + orderByChild: 'foo' + }); }); }); diff --git a/src/database/query_observable.ts b/src/database/query_observable.ts index a95f1a868..0eb5537da 100644 --- a/src/database/query_observable.ts +++ b/src/database/query_observable.ts @@ -23,8 +23,8 @@ export function observeQuery(query: Query): Observable { return Observable.create((observer: Observer) => { - let obs = getOrderObservables(query) as Observable; - combineLatest.call(obs, + combineLatest.call( + getOrderObservables(query), getStartAtObservable(query), getEndAtObservable(query), getEqualToObservable(query), @@ -80,7 +80,7 @@ export function observeQuery(query: Query): Observable { }); } -export function getOrderObservables(query: Query): Observable | Observable> { +export function getOrderObservables(query: Query): Observable { var observables = ['orderByChild', 'orderByKey', 'orderByValue', 'orderByPriority'] .map((key: string, option: OrderByOptions) => { return ({ key, option }) @@ -93,7 +93,7 @@ export function getOrderObservables(query: Query): Observable if (observables.length === 1) { return observables[0]; } else if (observables.length > 1) { - return merge.call(observables[0], observables.slice(1)); + return merge.apply(observables[0], observables.slice(1)); } else { return new Observable(subscriber => { subscriber.next(null); @@ -101,7 +101,7 @@ export function getOrderObservables(query: Query): Observable } } -export function getLimitToObservables(query: Query): Observable | Observable> { +export function getLimitToObservables(query: Query): Observable { var observables = ['limitToFirst', 'limitToLast'] .map((key: string, option: LimitToOptions) => ({ key, option })) .filter(({key, option}: { key: string, option: LimitToOptions }) => !isNil(query[key])) @@ -110,7 +110,7 @@ export function getLimitToObservables(query: Query): Observable 1) { - const mergedObs = merge.call(observables[0], observables.slice(1)); + const mergedObs = merge.apply(observables[0], observables.slice(1)); return mergedObs; } else { return new Observable(subscriber => {