API Reference
externalStore()
Build the tiny shape React's useSyncExternalStore expects, without importing React.
Import
import { externalStore } from "@graphrefly/ts/adapters";
Signature
function externalStore(
node: Node<T>,
opts: Pick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete"> = {},
): ExternalStore<T>
Parameters
| Parameter | Type | Description |
|---|---|---|
node | Node<T> | Node to observe, adapt, or connect. |
opts | Pick<SubscribeValuesOptions<T>, "getSnapshot" | "onError" | "onComplete"> | Options that configure the helper. |
Returns
A ExternalStore<T> value.
Example
import { externalStore } from "@graphrefly/ts/adapters";
Source
packages/ts/src/adapters/store.ts