Skip to content

Commit a1242f8

Browse files
committed
chore: update README
1 parent 06553f8 commit a1242f8

File tree

2 files changed

+58
-62
lines changed

2 files changed

+58
-62
lines changed

packages/event-bus-plugin/README.md

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,40 @@ This package is still under active development and might have breaking changes i
55
## General Usage
66

77
```tsx
8-
import { TanStackDevtoolsCore } from '@tanstack/devtools'
9-
10-
const devtools = new TanStackDevtoolsCore({
11-
options: {
12-
// your options here
13-
},
14-
plugins: [
15-
// your plugins here
16-
],
17-
})
18-
19-
devtools.mount(document.getElementById('your-devtools-container')!)
20-
```
8+
import { z } from 'zod'
9+
import { TanstackDevtoolsEventSubscription } from '@tanstack/devtools-event-bus-plugin'
10+
11+
const eventMap = {
12+
'query-devtools:test': z.object({
13+
title: z.string(),
14+
description: z.string(),
15+
}),
16+
'query-devtools:init': z.object({
17+
title: z.string(),
18+
description: z.string(),
19+
}),
20+
'query-devtools:query': z.object({
21+
title: z.string(),
22+
description: z.string(),
23+
}),
24+
}
25+
26+
class QueryDevtoolsPlugin extends TanstackDevtoolsEventSubscription<
27+
typeof eventMap
28+
> {
29+
constructor() {
30+
super({
31+
pluginId: 'query-devtools',
32+
})
33+
}
34+
}
35+
36+
export const queryPlugin = new QueryDevtoolsPlugin()
2137

22-
## Creating plugins
23-
24-
In order to create a plugin for TanStack Devtools, you can use the `plugins` arg of the `TanStackDevtoolsCore` class. Here's an example of how to create a simple plugin:
25-
26-
```ts
27-
import { TanStackDevtoolsCore } from '@tanstack/devtools'
28-
29-
const devtools = new TanStackDevtoolsCore({
30-
options: {
31-
// your options here
32-
},
33-
plugins: [
34-
{
35-
id: 'my-plugin',
36-
name: 'My Plugin',
37-
render: (el) => (el.innerHTML = '<div>My Plugin Content</div>'),
38-
},
39-
],
40-
})
4138
```
39+
40+
## Understanding the implementation
41+
42+
The `TanstackDevtoolsEventSubscription` class is a base class for creating plugins that can subscribe to events in the Tanstack Devtools event bus. It allows you to define a set of events and their corresponding data schemas using a standard-schema based schemas.
43+
44+
It will work on both the client/server side and all you have to worry about is emitting/listening to events.

packages/event-bus/README.md

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
1-
# @tanstack/devtools
1+
# @tanstack/devtools-event-bus
22

33
This package is still under active development and might have breaking changes in the future. Please use it with caution.
44

55
## General Usage
66

7+
### Server Event Bus
8+
79
```tsx
8-
import { TanStackDevtoolsCore } from '@tanstack/devtools'
9-
10-
const devtools = new TanStackDevtoolsCore({
11-
options: {
12-
// your options here
13-
},
14-
plugins: [
15-
// your plugins here
16-
],
17-
})
18-
19-
devtools.mount(document.getElementById('your-devtools-container')!)
20-
```
10+
import { TanstackDevtoolsServerEventBus } from '@tanstack/devtools-event-bus/server'
11+
// Start the server event bus
12+
const devtoolsServer = new TanstackDevtoolsServerEventBus()
13+
14+
devtoolsServer.start()
15+
16+
export { devtoolsServer }
2117

22-
## Creating plugins
18+
```
2319

24-
In order to create a plugin for TanStack Devtools, you can use the `plugins` arg of the `TanStackDevtoolsCore` class. Here's an example of how to create a simple plugin:
20+
### Client Event Bus
2521

2622
```ts
27-
import { TanStackDevtoolsCore } from '@tanstack/devtools'
28-
29-
const devtools = new TanStackDevtoolsCore({
30-
options: {
31-
// your options here
32-
},
33-
plugins: [
34-
{
35-
id: 'my-plugin',
36-
name: 'My Plugin',
37-
render: (el) => (el.innerHTML = '<div>My Plugin Content</div>'),
38-
},
39-
],
40-
})
23+
import { TanstackDevtoolsClientEventBus } from '@tanstack/devtools-event-bus/client'
24+
// Start the client event bus
25+
const devtoolsClient = new TanstackDevtoolsClientEventBus()
26+
27+
devtoolsClient.start()
28+
29+
export { devtoolsClient }
4130
```
31+
32+
## Plugins
33+
34+
Check out @tanstack/devtools-event-bus-plugin for more information on how to create plugins for the event bus.

0 commit comments

Comments
 (0)