@@ -22,6 +22,10 @@ import { DataSnapshot } from './DataSnapshot';
2222
2323let __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 ) ;
@@ -178,7 +182,7 @@ export class Query {
178182 * @param {?Object } context
179183 * @protected
180184 */
181- onChildEvent ( callbacks : { [ k : string ] : ( a : DataSnapshot , b : string | null ) => any } ,
185+ onChildEvent ( callbacks : { [ k : string ] : SnapshotCallback } ,
182186 cancelCallback : ( ( a : Error ) => any ) | null , context : Object | null ) {
183187 const container = new ChildEventRegistration ( callbacks , cancelCallback , context ) ;
184188 this . repo . addEventCallbackForQuery ( this , container ) ;
@@ -189,7 +193,7 @@ export class Query {
189193 * @param {(function(!DataSnapshot, ?string=))= } callback
190194 * @param {Object= } context
191195 */
192- off ( eventType ?: string , callback ?: ( a : DataSnapshot , b ?: string | null ) => any , context ?: Object ) {
196+ off ( eventType ?: string , callback ?: SnapshotCallback , context ?: Object ) {
193197 validateArgCount ( 'Query.off' , 0 , 3 , arguments . length ) ;
194198 validateEventType ( 'Query.off' , 1 , eventType , true ) ;
195199 validateCallback ( 'Query.off' , 2 , callback , true ) ;
@@ -218,10 +222,8 @@ export class Query {
218222 * @param context
219223 * @return {!firebase.Promise }
220224 */
221- once ( eventType : string ,
222- userCallback ?: ( a : DataSnapshot , b ?: string ) => any ,
223- cancelOrContext ?,
224- context ?: Object ) : Promise < DataSnapshot > {
225+ once ( eventType : string , userCallback ?: SnapshotCallback ,
226+ cancelOrContext ?: ( ( a : Error ) => void ) | Object , context ?: Object ) : Promise < DataSnapshot > {
225227 validateArgCount ( 'Query.once' , 1 , 4 , arguments . length ) ;
226228 validateEventType ( 'Query.once' , 1 , eventType , false ) ;
227229 validateCallback ( 'Query.once' , 2 , userCallback , true ) ;
@@ -379,7 +381,7 @@ export class Query {
379381 }
380382
381383 // Calling with no params tells us to start at the beginning.
382- if ( value == null ) {
384+ if ( value === undefined ) {
383385 value = null ;
384386 name = null ;
385387 }
0 commit comments