UNPKG

@langchain/langgraph-sdk

Version:

Client library for interacting with the LangGraph API

32 lines (31 loc) • 832 B
//#region src/stream/store.ts var StreamStore = class { #snapshot; #listeners = /* @__PURE__ */ new Set(); constructor(initial) { this.#snapshot = initial; } subscribe = (listener) => { this.#listeners.add(listener); return () => { this.#listeners.delete(listener); }; }; getSnapshot = () => this.#snapshot; /** Replace the snapshot and notify every listener. */ setValue = (next) => { if (Object.is(next, this.#snapshot)) return; this.#snapshot = next; for (const listener of this.#listeners) listener(); }; /** * Functional update. The `updater` receives the current snapshot and * MUST return a new object. Returning the same reference is a no-op. */ setState = (updater) => { this.setValue(updater(this.#snapshot)); }; }; //#endregion export { StreamStore }; //# sourceMappingURL=store.js.map