@langchain/langgraph-sdk
Version:
Client library for interacting with the LangGraph API
37 lines • 1.4 kB
TypeScript
//#region src/stream/store.d.ts
/**
* Minimal observable store backing every framework binding.
*
* The shape is intentionally tiny:
*
* - `subscribe(listener) → unsubscribe` lines up with React's
* `useSyncExternalStore`.
* - `getSnapshot()` returns a referentially-stable value for
* unchanged state so React can bail out of renders.
* - Vue/Svelte/Angular bindings wrap `subscribe` + `getSnapshot` in
* their own reactivity primitive (`shallowRef` / `writable` /
* `signal`) in ~10 lines.
*
* Snapshot identity matters: a listener is only useful if
* `getSnapshot()` returns a *different* reference when state changes.
* Callers MUST pass a freshly-constructed value to {@link setState};
* mutating the previous snapshot in place will break React's bail-out
* and cause infinite re-renders.
*/
type StoreListener = () => void;
declare class StreamStore<T> {
#private;
constructor(initial: T);
subscribe: (listener: StoreListener) => () => void;
getSnapshot: () => T;
/** Replace the snapshot and notify every listener. */
setValue: (next: T) => void;
/**
* Functional update. The `updater` receives the current snapshot and
* MUST return a new object. Returning the same reference is a no-op.
*/
setState: (updater: (previous: T) => T) => void;
}
//#endregion
export { StoreListener, StreamStore };
//# sourceMappingURL=store.d.ts.map