@assistant-ui/react
Version:
Typescript/React library for AI Chat
21 lines • 620 B
JavaScript
import { useDebugValue, useSyncExternalStore } from "react";
import { ensureBinding } from "./ensureBinding";
function useRuntimeStateInternal(runtime, selector = identity) {
ensureBinding(runtime);
const slice = useSyncExternalStore(
runtime.subscribe,
() => selector(runtime.getState()),
() => selector(runtime.getState())
);
useDebugValue(slice);
return slice;
}
const identity = (arg) => arg;
function useRuntimeState(runtime, selector) {
return useRuntimeStateInternal(runtime, selector);
}
export {
useRuntimeState,
useRuntimeStateInternal
};
//# sourceMappingURL=useRuntimeState.js.map