Skip to content

Commit 61c8d25

Browse files
committed
WIP: review adjustments #1
1 parent 25aeeed commit 61c8d25

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/database/api/Query.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import { DataSnapshot } from './DataSnapshot';
2222

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

25+
export interface SnapshotCallback {
26+
(a: DataSnapshot, b?: string): any
27+
}
28+
2529
/**
2630
* A Query represents a filter to be applied to a firebase location. This object purely represents the
2731
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
@@ -143,8 +147,8 @@ export class Query {
143147
* @param {Object=} context
144148
* @return {!function(DataSnapshot, string=)}
145149
*/
146-
on(eventType: string, callback: (a: DataSnapshot, b?: string) => any,
147-
cancelCallbackOrContext?: ((a: Error) => any) | Object, context?: Object): (a: DataSnapshot, b?: string) => any {
150+
on(eventType: string, callback: SnapshotCallback,
151+
cancelCallbackOrContext?: ((a: Error) => any) | Object, context?: Object): SnapshotCallback {
148152
validateArgCount('Query.on', 2, 4, arguments.length);
149153
validateEventType('Query.on', 1, eventType, false);
150154
validateCallback('Query.on', 2, callback, false);
@@ -177,7 +181,7 @@ export class Query {
177181
* @param {?function(Error)} cancelCallback
178182
* @param {?Object} context
179183
*/
180-
onChildEvent(callbacks: { [k: string]: (a: DataSnapshot, b: string | null) => any },
184+
onChildEvent(callbacks: { [k: string]: SnapshotCallback },
181185
cancelCallback: ((a: Error) => any) | null, context: Object | null) {
182186
const container = new ChildEventRegistration(callbacks, cancelCallback, context);
183187
this.repo.addEventCallbackForQuery(this, container);
@@ -188,7 +192,7 @@ export class Query {
188192
* @param {(function(!DataSnapshot, ?string=))=} callback
189193
* @param {Object=} context
190194
*/
191-
off(eventType?: string, callback?: (a: DataSnapshot, b?: string | null) => any, context?: Object) {
195+
off(eventType?: string, callback?: SnapshotCallback, context?: Object) {
192196
validateArgCount('Query.off', 0, 3, arguments.length);
193197
validateEventType('Query.off', 1, eventType, true);
194198
validateCallback('Query.off', 2, callback, true);
@@ -217,7 +221,7 @@ export class Query {
217221
* @param context
218222
* @return {!firebase.Promise}
219223
*/
220-
once(eventType: string, userCallback: (a: DataSnapshot, b?: string) => any,
224+
once(eventType: string, userCallback: SnapshotCallback,
221225
cancelOrContext?, context?: Object) {
222226
validateArgCount('Query.once', 1, 4, arguments.length);
223227
validateEventType('Query.once', 1, eventType, false);
@@ -376,7 +380,7 @@ export class Query {
376380
}
377381

378382
// Calling with no params tells us to start at the beginning.
379-
if (value == null) {
383+
if (value === undefined) {
380384
value = null;
381385
name = null;
382386
}

tests/config/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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 commit comments

Comments
 (0)