@shadow-js/core
The 82 exports of @shadow-js/core: 41 functions, 1 class, 23 interfaces, 13 types and 4 consts.
Everything @shadow-js/core exports, from the TSDoc of its entry point.
Functions#
batch: Runsfnwith effects deferred until the outermost batch ends, then runs them synchronously, so several writes wake each effect once.cache: Memoizesfnper request: within one root (a server render, or the app on the client) the same arguments return the same result without callingfnagain.catchError: Runsfninside a new child scope whose errors go tohandler: errors thrown synchronously byfn, and later errors of the effects, memos and cleanups it created.children: Memoizes aprops.childrengetter so that it is read at most once per change of its dependencies.createContext: Creates a context: a value that components read with useContext without passing it through props.createRef: Creates a Ref.createRoot: Creates an ownership scope.flushSync: Runsfn(optional) in a batch and runs every pending effect before returning, so the DOM and other effects are up to date on the next line.getOwner: Returns the owner that currently adopts new effects, memos and cleanups.indexArray: Maps each position of a list to a row.mapArray: Maps each item of a list to a row that lives as long as the item does.mergeProps: Merges props objects into one getter-preserving object.onCleanup: Registersfnto run when the current owner is disposed or, for an effect or memo, before it re-runs.onError: Registers an error handler on the current owner.onMount: Runsfnonce after the owner has been created and flushed, untracked, so signal changes never run it again.produce: Marks a draft updater.reconcile: Describes a new value for a store.runWithOwner: Runsfnwithowneras the current owner, untracked.snapshot: Returns a deep plain copy of a store's current data.splitProps: Splits props into one getter-preserving object per key list, followed by an object holding every other key.startTransition: Runsfnas a transition: the effects its writes wake wait in the transition lane, which runs after urgent work (in a macrotask, one chunk at a time).untrack: Runsfnwithout subscribing the running computation to anythingfnreads.unwrap: Returns the raw data behind a store.useAction: A state machine for a form-style action:dispatch(...args)runsaction(previous, ...args), tracks whether it is pending, and commits its result.useContext: Reads the nearest provided value ofcontext.useDeferredValue: Returns a value that followssourcein the transition lane: it keeps the previous value while urgent updates run, and takes the new value when the lane applies it.useEffect: Runs a side effect after rendering and again whenever a tracked signal changes.useEvent: A stable callback that always runs its handler untracked.useExternalStore: Reads a value that lives outside ShadowJS (a store, a browser API, an observable) as a reactive accessor.useId: Returns an id that is identical on server and client for the same position in the owner tree.useImperativeHandle: Publishes an imperative handle to a ref:create()runs once, untracked, and its result is passed toref; when the owner is disposedrefreceivesundefined.useMemo: Creates a cached derivation that recomputes only when a dependency actually changed.useOptimistic: Optimistic state: showsreducerapplied over the real value for every action whosesettledpromise is still pending.useReaction: Creates a tracker that reports the first change of what it reads.useReducer: A state cell whose writes go through a reducer:dispatch(action)storesreducer(state, action).useRenderEffect: Like useEffect but belongs to the render phase: it runs synchronously when created and before user effects on every flush.useResource: Loads data asynchronously and exposes it reactively.useSelector: Creates a selection set oversource.useSignal: Creates a reactive cell holding one value: the low-level primitiveuseStorebuilds on.useStore: The state hook.useTransition: Runsfnas a transition and reports whether it is pending.
Classes#
Owner: A node in the ownership tree: it owns the effects, memos and owners created under it, their cleanups and error handlers, and disposes them together.
Interfaces#
CacheOptions: Options of cache.Context: A context made by createContext: a value that a subtree receives from the nearest provider above it.ContextOptions: Options of createContext.DeferredEffectOptions: Options of useEffect in its explicit-dependency formuseEffect(deps, fn, options).DeferredValueOptions: Options of useDeferredValue.EffectOptions: Options of useEffect in its tracking formuseEffect(fn, options).ExternalStoreOptions: Options of useExternalStore.MemoOptions: Options of useMemo.ReconcileOptions: Options of reconcile.ReducerOptions: Options of useReducer.Ref: A ref object that is also a ref callback: pass it asref={r}(the renderer calls it with the element) and read the element asr.current.ResolvedChildren: The value returned by children: calling it yields one leaf, an array of several leaves, orundefinedfor none;toArray()always returns an array.Resource: Reactive handle to an asynchronous value.ResourceCache: Bridge between resources and the server/hydration runtime.ResourceInfo: Passed to every fetcher call.ResourceOptions: Options of useResource.ResourceTrackOptions: What ResourceCache.track is told about a fetch.RootOptions: Options of createRoot.SetStore: Updates a store.Setter: The writer of a signal: it stores a value, or the result of an updater called with the previous value, and returns what it stored.SignalOptions: Options of useSignal.StoreOptions: Options of useStore.SuspenseTracker: Counter protocol between asynchronous sources and the nearest<Suspense>boundary.
Types#
Accessor: A reactive read: calling it returns the current value, and subscribes the running effect or memo to it when one is listening.Cleanup: A function that releases what an owner or an effect set up: a timer, a subscription, a listener.Equals: The equality that decides whether a write or a recomputation is a change: readers are notified only when it returns false.ErrorHandler: A function that receives an error routed to an owner, as registered withonErrororcatchError.ListSource: A list as the list primitives read it.MergeProps: The type ofmergeProps(...sources), folded left to right: a later source's key replaces an earlier one, and a later key that may beundefinedkeeps the earlier type as well.MergeSource: A value accepted by mergeProps: an object, a function that returns one (called at every read, so it can be reactive), ornull,undefinedorfalse, which are skipped.Mutable: Writable counterpart of a value:readonlyis removed at every depth.Reconciler: Value produced by reconcile.ResourceState: Where a Resource is in its life:"unresolved"(no value and no fetch, for example while the source is falsy),"pending"(the first fetch is in flight),"ready"(a value is shown and nothing is in flight),"refreshing"(a value is shown while a newer fetch runs) or"errored"(the last fetch failed; reading the resource throws).SplitProps: The type ofsplitProps(props, ...keyLists): one object per key list, picking those keys, then the rest without any listed key.Store: Read-only view ofT.StoreResult: WhatuseStore(initial)returns:[store, setStore]for plain data, and an[accessor, setter]pair for a single value, including a value that may be plain data ornull(Todo[] \| null).
Constants#
isDev: True in development builds; false in production builds where__DEV__is compiled away.isServer: True in the server condition build, where effects never run and rendering produces strings.ResourceCacheContext: The context through whichuseResourcereaches the renderer's ResourceCache.SuspenseContext: The context through which an asynchronous source finds the nearest<Suspense>boundary.