Skip to content

Commit a1451c4

Browse files
committed
Throw error if callback isn't a function rather than check each time an event is received
1 parent fa96855 commit a1451c4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/modules/database/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default class Database extends Base {
176176

177177
if (this.subscriptions[handle] && this.subscriptions[handle][eventName]) {
178178
this.subscriptions[handle][eventName].forEach((cb) => {
179-
if (isFunction(cb)) cb(new Snapshot(this, snapshot), body);
179+
cb(new Snapshot(this, snapshot), body);
180180
});
181181
} else {
182182
FirestackDatabase.off(path, modifiersString, eventName, () => {

lib/modules/database/reference.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export default class Reference extends ReferenceBase {
9696
}
9797

9898
on(eventName: string, cb: () => any) {
99+
if (!isFunction(cb)) throw new Error('The specified callback must be a function');
99100
const path = this._dbPath();
100101
const modifiers = this.query.getModifiers();
101102
const modifiersString = this.query.getModifiersString();

0 commit comments

Comments
 (0)