Skip to content

Commit 9dabc28

Browse files
Propagating RTDB type changes
This is a follow-up PR to #840
1 parent 87b274b commit 9dabc28

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/database/src/api/DataSnapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class DataSnapshot {
133133
* @return {boolean} True if forEach was canceled by action returning true for
134134
* one of the child nodes.
135135
*/
136-
forEach(action: (d: DataSnapshot) => void): boolean {
136+
forEach(action: (d: DataSnapshot) => boolean|void): boolean {
137137
validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
138138
validateCallback('DataSnapshot.forEach', 1, action, false);
139139

packages/database/src/core/snap/ChildrenNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class ChildrenNode implements Node {
324324
/**
325325
* @inheritDoc
326326
*/
327-
forEachChild(index: Index, action: (key: string, node: Node) => void): any {
327+
forEachChild(index: Index, action: (key: string, node: Node) => boolean|void): any {
328328
const idx = this.resolveIndex_(index);
329329
if (idx) {
330330
return idx.inorderTraversal(function(wrappedNode) {

packages/firebase/index.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ declare namespace firebase.database {
428428
child(path: string): firebase.database.DataSnapshot;
429429
exists(): boolean;
430430
exportVal(): any;
431-
forEach(action: (a: firebase.database.DataSnapshot) => boolean): boolean;
431+
forEach(action: (a: firebase.database.DataSnapshot) => boolean | void): boolean;
432432
getPriority(): string | number | null;
433433
hasChild(path: string): boolean;
434434
hasChildren(): boolean;
@@ -459,6 +459,8 @@ declare namespace firebase.database {
459459
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
460460
}
461461

462+
type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';
463+
462464
interface Query {
463465
endAt(
464466
value: number | string | boolean | null,
@@ -472,22 +474,22 @@ declare namespace firebase.database {
472474
limitToFirst(limit: number): firebase.database.Query;
473475
limitToLast(limit: number): firebase.database.Query;
474476
off(
475-
eventType?: string,
477+
eventType?: EventType,
476478
callback?: (a: firebase.database.DataSnapshot, b?: string | null) => any,
477479
context?: Object | null
478480
): any;
479481
on(
480-
eventType: string,
482+
eventType: EventType,
481483
callback: (a: firebase.database.DataSnapshot | null, b?: string) => any,
482484
cancelCallbackOrContext?: Object | null,
483485
context?: Object | null
484486
): (a: firebase.database.DataSnapshot | null, b?: string) => any;
485487
once(
486-
eventType: string,
488+
eventType: EventType,
487489
successCallback?: (a: firebase.database.DataSnapshot, b?: string) => any,
488490
failureCallbackOrContext?: Object | null,
489491
context?: Object | null
490-
): Promise<any>;
492+
): Promise<DataSnapshot>;
491493
orderByChild(path: string): firebase.database.Query;
492494
orderByKey(): firebase.database.Query;
493495
orderByPriority(): firebase.database.Query;

0 commit comments

Comments
 (0)