Spaces:
Sleeping
Sleeping
debouce
Browse files
frontend/src/lib/store.ts
CHANGED
@@ -1,7 +1,15 @@
|
|
1 |
|
2 |
-
import {
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
export const pipelineValues = writable({} as Record<string, any>);
|
7 |
export const getPipelineValues = () => get(pipelineValues);
|
|
|
1 |
|
2 |
+
import { derived, writable, get, type Writable, type Readable } from 'svelte/store';
|
3 |
+
|
4 |
+
export const pipelineValues: Writable<Record<string, any>> = writable({});
|
5 |
+
export const deboucedPipelineValues: Readable<Record<string, any>>
|
6 |
+
= derived(pipelineValues, ($pipelineValues, set) => {
|
7 |
+
const debounced = setTimeout(() => {
|
8 |
+
set($pipelineValues);
|
9 |
+
}, 100);
|
10 |
+
return () => clearTimeout(debounced);
|
11 |
+
});
|
12 |
+
|
13 |
+
|
14 |
|
|
|
15 |
export const getPipelineValues = () => get(pipelineValues);
|
frontend/src/routes/+page.svelte
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
onFrameChangeStore,
|
16 |
MediaStreamStatusEnum
|
17 |
} from '$lib/mediaStream';
|
18 |
-
import { getPipelineValues,
|
19 |
|
20 |
let pipelineParams: FieldProps[];
|
21 |
let pipelineInfo: PipelineInfo;
|
@@ -49,7 +49,7 @@
|
|
49 |
// send only prompt if text mode
|
50 |
$: {
|
51 |
if ($lcmLiveStatus === LCMLiveStatus.CONNECTED) {
|
52 |
-
lcmLiveActions.send($
|
53 |
}
|
54 |
}
|
55 |
|
|
|
15 |
onFrameChangeStore,
|
16 |
MediaStreamStatusEnum
|
17 |
} from '$lib/mediaStream';
|
18 |
+
import { getPipelineValues, deboucedPipelineValues } from '$lib/store';
|
19 |
|
20 |
let pipelineParams: FieldProps[];
|
21 |
let pipelineInfo: PipelineInfo;
|
|
|
49 |
// send only prompt if text mode
|
50 |
$: {
|
51 |
if ($lcmLiveStatus === LCMLiveStatus.CONNECTED) {
|
52 |
+
lcmLiveActions.send($deboucedPipelineValues);
|
53 |
}
|
54 |
}
|
55 |
|