Skip to content

Commit 2aac6bc

Browse files
committed
remove namespace from base, conflicts on class extension
1 parent 35c3e27 commit 2aac6bc

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

lib/modules/base.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ export class Base extends EventEmitter {
6262
});
6363
}
6464

65-
get namespace(): string {
66-
return 'firestack:base';
67-
}
68-
6965
// Event handlers
7066
// proxy to firestack instance
7167
_on(name, cb, nativeModule) {

lib/modules/database/index.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,9 @@ export default class Database extends Base {
7171
const handle = this._handle(path, modifiersString);
7272
this.log.debug('adding on listener', handle);
7373

74-
if (this.subscriptions[handle]) {
75-
if (this.subscriptions[handle][eventName]) this.subscriptions[handle][eventName].push(cb);
76-
else this.subscriptions[handle][eventName] = [cb];
77-
} else {
78-
this.subscriptions[handle] = { [eventName]: [cb] };
79-
}
74+
if (!this.subscriptions[handle]) this.subscriptions[handle] = {};
75+
if (!this.subscriptions[handle][eventName]) this.subscriptions[handle][eventName] = [];
76+
this.subscriptions[handle][eventName].push(cb);
8077

8178
return promisify('on', FirestackDatabase)(path, modifiersString, modifiers, eventName);
8279
}
@@ -100,16 +97,14 @@ export default class Database extends Base {
10097

10198
if (eventName && origCB) {
10299
const i = this.subscriptions[handle][eventName].indexOf(origCB);
100+
103101
if (i === -1) {
104-
this.log.warn('off() called, but the callback specifed is not listening at that location (bad path)', handle, eventName);
102+
this.log.warn('off() called, but the callback specified is not listening at that location (bad path)', handle, eventName);
105103
return Promise.resolve();
106104
}
107105

108-
this.subscriptions[handle][eventName] = this.subscriptions[handle][eventName].splice(i, 1);
109-
110-
if (this.subscriptions[handle][eventName].length > 0) {
111-
return Promise.resolve();
112-
}
106+
this.subscriptions[handle][eventName].splice(i, 1);
107+
if (this.subscriptions[handle][eventName].length > 0) return Promise.resolve();
113108
} else if (eventName) {
114109
this.subscriptions[handle][eventName] = [];
115110
} else {

0 commit comments

Comments
 (0)