Skip to content

Commit 8b54166

Browse files
committed
core.Observable: addListener() => remove default values from the eventConfig #6657
1 parent 455cbd3 commit 8b54166

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/core/Observable.mjs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,12 @@ class Observable extends Base {
101101
}
102102

103103
if (!nameObject) {
104-
eventConfig = {
105-
data,
106-
delay,
107-
fn: listener,
108-
id: eventId || Neo.getId('event'),
109-
once,
110-
scope
111-
};
104+
eventConfig = {fn: listener, id: eventId || Neo.getId('event')};
105+
106+
if (data) {eventConfig.data = data}
107+
if (delay > 0) {eventConfig.delay = delay}
108+
if (once) {eventConfig.once = once}
109+
if (scope) {eventConfig.scope = scope}
112110

113111
if (existing = me.listeners?.[name]) {
114112
existing.forEach(cfg => {
@@ -194,10 +192,6 @@ class Observable extends Base {
194192
// look in the ownership hierarchy from me.
195193
const cb = resolveCallback(handler.fn, handler.scope || me);
196194

197-
if (Neo.isString(cb.fn)) {
198-
console.log(name, handler, cb);
199-
}
200-
201195
// remove the listener if the scope no longer exists
202196
if (cb.scope && !cb.scope.id) {
203197
NeoArray.remove(listeners[name], handler)

0 commit comments

Comments
 (0)