Skip to content

Commit 5401a62

Browse files
committed
refactor: simplify onAllPluginEvents implementation
1 parent 67be66c commit 5401a62

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

packages/event-bus-client/src/plugin.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,22 +331,11 @@ export class EventClient<
331331
)
332332
}
333333
onAllPluginEvents(cb: (event: AllDevtoolsEvents<TEventMap>) => void) {
334-
if (!this.#enabled) {
335-
this.debugLog('Event bus client is disabled, not registering event')
336-
return () => {}
337-
}
338-
const handler = (e: Event) => {
339-
const event = (e as CustomEvent).detail
334+
return this.onAll((event) => {
340335
if (this.#pluginId && event.pluginId !== this.#pluginId) {
341336
return
342337
}
343338
cb(event)
344-
}
345-
this.#eventTarget().addEventListener('tanstack-devtools-global', handler)
346-
return () =>
347-
this.#eventTarget().removeEventListener(
348-
'tanstack-devtools-global',
349-
handler,
350-
)
339+
})
351340
}
352341
}

0 commit comments

Comments
 (0)