MCPcopy Create free account
hub / github.com/TanStack/devtools / createCounter

Function createCounter

examples/react/custom-devtools/src/counter.ts:3–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { DevtoolsEventClient } from './eventClient.ts'
2
3export function createCounter() {
4 let count = 0
5 const history: Array<number> = []
6
7 return {
8 getCount: () => count,
9 increment: () => {
10 count++
11 history.push(count)
12
13 // The emit eventSuffix must match that of the EventMap defined in eventClient.ts
14 DevtoolsEventClient.emit('counter-state', {
15 count,
16 history,
17 })
18 },
19 decrement: () => {
20 count--
21 history.push(count)
22
23 DevtoolsEventClient.emit('counter-state', {
24 count,
25 history,
26 })
27 },
28 }
29}

Callers 1

App.tsxFile · 0.90

Calls 1

emitMethod · 0.45

Tested by

no test coverage detected