Skip to content

Commit 4c47ef1

Browse files
committed
Cleanup debugger
1 parent 4c32aca commit 4c47ef1

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

packages/debugger/src/main/index.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {DebuggerModule, DEFAULT_MAIN_VIEW, DevtoolsMainView, TreeWalkerMode} fro
1212
import {getObjectById, getSdtId, ObjectType} from './id.ts'
1313
import setup from './setup.ts'
1414
import {type Mapped, type NodeID} from './types.ts'
15-
import {createBatchedUpdateEmitter} from './utils.ts'
1615

1716
export namespace Debugger {
1817
export type InspectedState = {
@@ -169,9 +168,21 @@ s.createComputed(
169168
)
170169

171170
// Computation and signal updates
172-
const pushNodeUpdate = createBatchedUpdateEmitter<NodeID>(updates => {
173-
hub.output.emit('NodeUpdates', updates)
174-
})
171+
let node_updates_ids: NodeID[] = []
172+
let node_updates_timeout = 0
173+
174+
function pushNodeUpdate(id: NodeID) {
175+
176+
node_updates_ids.push(id)
177+
178+
if (node_updates_timeout === 0) {
179+
node_updates_timeout = window.setTimeout(() => {
180+
hub.output.emit('NodeUpdates', node_updates_ids)
181+
node_updates_ids = []
182+
node_updates_timeout = 0
183+
})
184+
}
185+
}
175186

176187
//
177188
// Structure:

packages/debugger/src/main/utils.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import {trimString} from '@solid-devtools/shared/utils'
2-
import {type Emit} from '@solid-primitives/event-bus'
3-
import {throttle} from '@solid-primitives/scheduled'
42
import {NodeType} from './constants.ts'
53
import {type Solid} from './types.ts'
64
import setup from './setup.ts'
@@ -245,22 +243,3 @@ export function onOwnerDispose(
245243
if (isSolidRoot(owner)) return onOwnerCleanup(owner, fn, prepend, symbol)
246244
return onParentCleanup(owner, fn, prepend, symbol)
247245
}
248-
249-
/**
250-
* Batches series of updates to a single array of updates.
251-
*
252-
* The updates are deduped by `id` property
253-
*/
254-
export function createBatchedUpdateEmitter<T>(emit: Emit<T[]>): (update: T) => void {
255-
const updates = new Set<T>()
256-
257-
const triggerUpdateEmit = throttle(() => {
258-
emit([...updates])
259-
updates.clear()
260-
})
261-
262-
return update => {
263-
updates.add(update)
264-
triggerUpdateEmit()
265-
}
266-
}

0 commit comments

Comments
 (0)