You are reading the docs for 0.9. The latest version is 0.10. Read this page for 0.10 →

Yoltra<R extends string, S extends Record<R, any>, EM extends EventMapBase>

interface
react/src/createYoltra.tsx:40

extends YoltraHooks<R, S, EM>, YoltraDecoration<R, S, EM>

The value returned by createYoltra: the created store, an optional StoreProvider (plus its raw StoreContext), and the full set of typed hooks from YoltraHooks.

Type parameters

NameTypeDescription
Rextends stringReducer name union.
Sextends Record<R, any>State record keyed by R.
EMextends EventMapBaseEvent map.

Properties

NameTypeDescription
shallowEqual(a: T, b: T) => booleanShallow object equality using Object.is per-key.
storeStoreInstance<R, S, EM>The store created by this call; the hooks default to it (no Provider needed).
StoreContextContext<null | StoreInstance<R, S, EM>>Raw context carrying the store, usually you only need StoreProvider.
StoreProviderFC<{ children: ReactNode; store?: StoreInstance<R, S, EM> }>Optional provider to scope a different store instance to a subtree.
useAtomicPropUseAtomicProp<R, S>Subscribes to a single dotted path (or typed accessor).
useAtomicPropsUseAtomicProps<R, S>Subscribes to several paths and derives a value from the full state.
useEmit() => Emit<EM>Returns the store's typed emit.
useEventUseEvent<EM, S>Runs a handler for a specific (channel, type) event.
useSelector(selector: (state: DeepReadonly<S>) => T, isEqual?: (a: T, b: T) => boolean) => TSubscribes to a derived value with an optional equality comparator.
useStore() => StoreInstance<R, S, EM>Reads the current store from context (falling back to the default store).
useSuspenseAtomicPropUseSuspenseAtomicProp<R, S>Suspense-loading variant of useAtomicProp, bound to the same context.
useSuspenseAtomicPropsUseSuspenseAtomicProps<R, S>Suspense-loading variant of useAtomicProps, bound to the same context.

Methods

withEffect

Registers an effect and returns a Yoltra widened by whatever event map it declares.

signature
withEffect<Spec>(spec): DecoratableYoltra<R, S, Merge<EM, EMAddOf<Spec>>>

Registers an effect and returns a Yoltra widened by whatever event map it declares.

Type parameters

NameTypeDescription
Specextends EffectSpec<any, any>

Parameters

NameTypeDescription
specSpec

Returns

DecoratableYoltra<R, S, Merge<EM, EMAddOf<Spec>>>

withMiddleware

Registers middleware and returns a Yoltra widened by whatever event map it declares. Only the spec form can widen; a bare MiddlewareFunction contributes nothing, because its event parameter is EventUnion<EM> and TypeScript cannot infer EM back out of it.

signature
withMiddleware<M>(mw): DecoratableYoltra<R, S, Merge<EM, EMAddOf<M>>>

Registers middleware and returns a Yoltra widened by whatever event map it declares. Only the spec form can widen; a bare MiddlewareFunction contributes nothing, because its event parameter is EventUnion<EM> and TypeScript cannot infer EM back out of it.

Type parameters

NameTypeDescription
Mextends MiddlewareInput<any, any>

Parameters

NameTypeDescription
mwM

Returns

DecoratableYoltra<R, S, Merge<EM, EMAddOf<M>>>

withSlice

Mounts a slice and returns a widened Yoltra: the same store, a new hook set.

signature
withSlice<N, Spec>(name, spec, options?): DecoratableYoltra<WidenNames<R, N>, { [K in string | number | symbol]: WidenState<S, N, StateOfSpec<Spec>> & Record<WidenNames<R, N>, unknown>[K] }, Merge<EM, EMAddOf<Spec>>>

Mounts a slice and returns a widened Yoltra: the same store, a new hook set.

Type parameters

NameTypeDescription
Nextends string
Specextends ReducerSpec<any, any>

Parameters

NameTypeDescription
nameN
NameTypeDescription
specSpec

options, object with:

NameTypeDescription
owner?string

Returns

DecoratableYoltra<WidenNames<R, N>, { [K in string | number | symbol]: WidenState<S, N, StateOfSpec<Spec>> & Record<WidenNames<R, N>, unknown>[K] }, Merge<EM, EMAddOf<Spec>>>