Skip to content

Commit 1cd2e9f

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

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

.changeset/cyan-carrots-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/devtools-event-client': patch
3+
---
4+
5+
Simplify implementation of `onAllPluginEvents`, for bundle-size

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)