devtools-bidirectional
devtools-bidirectional
Prerequisite: Read and understand the
devtools-event-clientskill first. This skill builds onEventClient, its event map types,emit()/on()API, pluginId namespacing, connection lifecycle, and singleton pattern. Everything here assumes you already have a workingEventClientinstance.
Two-way communication between your application and a TanStack Devtools panel using EventClient. The same client instance handles both directions: the app emits observation events that the panel listens to, and the panel emits command events that the app listens to.
Core Concept
EventClient is not unidirectional. Both emit() and on() work from either side -- application code or panel code -- on the same shared event bus. The direction is a convention you establish through your event map design, not a limitation of the API.
App code calls: client.emit('state-update', ...) // observation
Panel code calls: client.on('state-update', ...) // observation
Panel code calls: client.emit('set-state', ...) // command
App code calls: client.on('set-state', ...) // command