From 1cd2e9fd88b159f3fa0a8b1fcd4d68086bf73e8a Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Tue, 13 Jan 2026 12:52:19 +0100 Subject: [PATCH] refactor: simplify `onAllPluginEvents` implementation --- .changeset/cyan-carrots-warn.md | 5 +++++ packages/event-bus-client/src/plugin.ts | 15 ++------------- 2 files changed, 7 insertions(+), 13 deletions(-) create mode 100644 .changeset/cyan-carrots-warn.md diff --git a/.changeset/cyan-carrots-warn.md b/.changeset/cyan-carrots-warn.md new file mode 100644 index 00000000..9ab3fe11 --- /dev/null +++ b/.changeset/cyan-carrots-warn.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools-event-client': patch +--- + +Simplify implementation of `onAllPluginEvents`, for bundle-size diff --git a/packages/event-bus-client/src/plugin.ts b/packages/event-bus-client/src/plugin.ts index 99b36151..24b1f9ac 100644 --- a/packages/event-bus-client/src/plugin.ts +++ b/packages/event-bus-client/src/plugin.ts @@ -331,22 +331,11 @@ export class EventClient< ) } onAllPluginEvents(cb: (event: AllDevtoolsEvents) => void) { - if (!this.#enabled) { - this.debugLog('Event bus client is disabled, not registering event') - return () => {} - } - const handler = (e: Event) => { - const event = (e as CustomEvent).detail + return this.onAll((event) => { if (this.#pluginId && event.pluginId !== this.#pluginId) { return } cb(event) - } - this.#eventTarget().addEventListener('tanstack-devtools-global', handler) - return () => - this.#eventTarget().removeEventListener( - 'tanstack-devtools-global', - handler, - ) + }) } }