Open History to see the last commit
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}