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

interface
react/src/createYoltra.tsx:68

The chainable decoration surface on a Yoltra.

Yoltra extends this, so every hook set is chainable. Every method returns a **new hook set bound to the same context object**, re-typed. The context is never recreated, so a StoreProvider from any view in the chain serves the hooks of every other, and the Suspense cache is shared - it keys on store identity through a WeakMap, and the widened store is the same object. Call these at **module scope, once, before first render**. createHooks allocates fresh function objects per call, so decorating inside a component would hand React a different hook set on every render.

Type parameters

NameTypeDescription
Rextends string
Sextends Record<R, any>
EMextends EventMapBase

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>>>