Skip to content

Commit 1e51f99

Browse files
jsayolJosep Sayol
authored and
Josep Sayol
committed
WIP: fix error when checking EventRegistration callbacks
1 parent 1d228fa commit 1e51f99

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/database/core/view/EventRegistration.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DataSnapshot } from '../../api/DataSnapshot';
22
import { DataEvent, CancelEvent, Event } from './Event';
3-
import { contains, getCount, getAnyKey } from '../../../utils/obj';
3+
import { contains, getCount, getAnyKey, every } from '../../../utils/obj';
44
import { assert } from '../../../utils/assert';
55
import { Path } from '../util/Path';
66
import { Change } from './Change';
@@ -241,9 +241,7 @@ export class ChildEventRegistration implements EventRegistration {
241241
);
242242
} else {
243243
// Exact match on each key.
244-
return this.callbacks_.every(<any>function (cb, eventType) {
245-
return other.callbacks_[eventType] === cb;
246-
});
244+
return every(this.callbacks_, (eventType, cb) => other.callbacks_[eventType] === cb);
247245
}
248246
}
249247
}

src/utils/obj.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,15 @@ export const getValues = function(obj) {
110110
res[i++] = obj[key];
111111
}
112112
return res;
113-
};
113+
};
114+
115+
export const every = function(obj, fn) {
116+
for (let key in obj) {
117+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
118+
if (!fn(key, obj[key])) {
119+
return false;
120+
}
121+
}
122+
}
123+
return true;
124+
};

0 commit comments

Comments
 (0)