MCPcopy
hub / github.com/slowlydev/f1-dash / useStatefulBuffer

Function useStatefulBuffer

dashboard/src/hooks/useStatefulBuffer.ts:9–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import type { RecursivePartial } from "@/types/message.type";
8
9export const useStatefulBuffer = <T>() => {
10 const currentRef = useRef<T | null>(null);
11 const buffer = useBuffer<T>();
12
13 const push = (update: RecursivePartial<T>) => {
14 currentRef.current = merge(currentRef.current ?? {}, update) as T;
15 if (currentRef.current) buffer.push(currentRef.current);
16 };
17
18 return {
19 push,
20 latest: buffer.latest,
21 delayed: buffer.delayed,
22 cleanup: buffer.cleanup,
23 maxDelay: buffer.maxDelay,
24 };
25};

Callers 1

useDataEngineFunction · 0.90

Calls 1

useBufferFunction · 0.90

Tested by

no test coverage detected