Skip to content

Commit

Permalink
WIP: review adjustments #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcrowthe committed Jun 28, 2017
1 parent 25aeeed commit f108014
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/database/api/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import { DataSnapshot } from './DataSnapshot';

let __referenceConstructor: new(repo: Repo, path: Path) => Query;

export interface SnapshotCallback {
(a: DataSnapshot, b?: string): any
}

/**
* A Query represents a filter to be applied to a firebase location. This object purely represents the
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
Expand Down Expand Up @@ -143,8 +147,8 @@ export class Query {
* @param {Object=} context
* @return {!function(DataSnapshot, string=)}
*/
on(eventType: string, callback: (a: DataSnapshot, b?: string) => any,
cancelCallbackOrContext?: ((a: Error) => any) | Object, context?: Object): (a: DataSnapshot, b?: string) => any {
on(eventType: string, callback: SnapshotCallback,
cancelCallbackOrContext?: ((a: Error) => any) | Object, context?: Object): SnapshotCallback {
validateArgCount('Query.on', 2, 4, arguments.length);
validateEventType('Query.on', 1, eventType, false);
validateCallback('Query.on', 2, callback, false);
Expand Down Expand Up @@ -177,7 +181,7 @@ export class Query {
* @param {?function(Error)} cancelCallback
* @param {?Object} context
*/
onChildEvent(callbacks: { [k: string]: (a: DataSnapshot, b: string | null) => any },
onChildEvent(callbacks: { [k: string]: SnapshotCallback },
cancelCallback: ((a: Error) => any) | null, context: Object | null) {
const container = new ChildEventRegistration(callbacks, cancelCallback, context);
this.repo.addEventCallbackForQuery(this, container);
Expand Down Expand Up @@ -217,7 +221,7 @@ export class Query {
* @param context
* @return {!firebase.Promise}
*/
once(eventType: string, userCallback: (a: DataSnapshot, b?: string) => any,
once(eventType: string, userCallback: SnapshotCallback,
cancelOrContext?, context?: Object) {
validateArgCount('Query.once', 1, 4, arguments.length);
validateEventType('Query.once', 1, eventType, false);
Expand Down Expand Up @@ -376,7 +380,7 @@ export class Query {
}

// Calling with no params tells us to start at the beginning.
if (value == null) {
if (value === undefined) {
value = null;
name = null;
}
Expand Down
1 change: 1 addition & 0 deletions tests/config/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"apiKey":"AIzaSyBNHCyZ-bpv-WA-HpXTmigJm2aq3z1kaH8","authDomain":"jscore-sandbox-141b5.firebaseapp.com","databaseURL":"https://jscore-sandbox-141b5.firebaseio.com","projectId":"jscore-sandbox-141b5","storageBucket":"jscore-sandbox-141b5.appspot.com","messagingSenderId":"280127633210"}

0 comments on commit f108014

Please sign in to comment.