Skip to content

Commit 96a4f79

Browse files
committed
feat: throttle component highlight
See #1888
1 parent 1fcec44 commit 96a4f79

File tree

1 file changed

+12
-5
lines changed
  • packages/app-frontend/src/features/components/composable

1 file changed

+12
-5
lines changed

packages/app-frontend/src/features/components/composable/highlight.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import { useBridge } from '@front/features/bridge'
1+
import { getBridge } from '@front/features/bridge'
22
import { BridgeEvents } from '@vue-devtools/shared-utils'
33
import { Ref } from 'vue'
4+
import throttle from 'lodash/throttle'
45

5-
export function useComponentHighlight (id: Ref<string>) {
6-
const { bridge } = useBridge()
6+
const throttledSend = throttle((id?: string) => {
7+
if (id) {
8+
getBridge().send(BridgeEvents.TO_BACK_COMPONENT_MOUSE_OVER, id)
9+
} else {
10+
getBridge().send(BridgeEvents.TO_BACK_COMPONENT_MOUSE_OUT)
11+
}
12+
}, 200)
713

14+
export function useComponentHighlight (id: Ref<string>) {
815
function highlight () {
9-
bridge.send(BridgeEvents.TO_BACK_COMPONENT_MOUSE_OVER, id.value)
16+
throttledSend(id.value)
1017
}
1118

1219
function unhighlight () {
13-
bridge.send(BridgeEvents.TO_BACK_COMPONENT_MOUSE_OUT)
20+
throttledSend(null)
1421
}
1522

1623
return {

0 commit comments

Comments
 (0)