updux/docs-docsidy/api/classes/default.md
2024-08-08 09:28:44 -04:00

19 KiB

updux / Exports / default

Class: default<D>

Type parameters

Name Type
D extends DuxConfig

Constructors

constructor

new default<D>(duxConfig): default<D>

Type parameters

Name Type
D extends Partial<{ actions: Record<string, any> ; initialState: any ; reducer: unknown ; schema: Record<string, any> ; selectors: Record<string, any> ; subduxes: Record<string, Partial<{ initialState: any; schema: Record<string, any>; actions: Record<string, any>; subduxes: Record<string, Partial<...>>; reducer: unknown; selectors: Record<string, any>; }>> }>

Parameters

Name Type
duxConfig D

Returns

default<D>

Properties

#defaultMutation

Private #defaultMutation: any


#effects

Private #effects: any[] = []


#mutations

Private #mutations: any[] = []


#reactions

Private #reactions: any[] = []


duxConfig

Private Readonly duxConfig: D


memoBuildActions

memoBuildActions: Moized<(localActions: {}, subduxes: {}) => any, Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<(localActions: {}, subduxes: {}) => any> ; onCacheChange: OnCacheOperation<(localActions: {}, subduxes: {}) => any> ; onCacheHit: OnCacheOperation<(localActions: {}, subduxes: {}) => any> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<Moizeable> ; onCacheChange: OnCacheOperation<Moizeable> ; onCacheHit: OnCacheOperation<Moizeable> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & { maxSize: number = 1 }>


memoBuildEffects

memoBuildEffects: Moized<(localEffects: any, subduxes: {}) => any[], Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<(localEffects: any, subduxes: {}) => any[]> ; onCacheChange: OnCacheOperation<(localEffects: any, subduxes: {}) => any[]> ; onCacheHit: OnCacheOperation<(localEffects: any, subduxes: {}) => any[]> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<Moizeable> ; onCacheChange: OnCacheOperation<Moizeable> ; onCacheHit: OnCacheOperation<Moizeable> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & { maxSize: number = 1 }>


memoBuildReducer

memoBuildReducer: Moized<(initialStateState: unknown, mutations: MutationCase[], defaultMutation?: Omit<MutationCase, "matcher">, subduxes: Record<string, Partial<{ actions: Record<string, any> ; initialState: any ; reducer: unknown ; schema: Record<string, any> ; selectors: Record<string, any> ; subduxes: Record<string, Partial<{ initialState: any; schema: Record<string, any>; actions: Record<string, any>; subduxes: Record<string, Partial<...>>; reducer: unknown; selectors: Record<...>; }>> }>>) => (state: unknown, action: Action<any>) => unknown, Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<(initialStateState: unknown, mutations: MutationCase[], defaultMutation?: Omit<MutationCase, "matcher">, subduxes: Record<string, Partial<{ actions: Record<string, any> ; initialState: any ; reducer: unknown ; schema: Record<string, any> ; selectors: Record<string, any> ; subduxes: Record<string, Partial<{ initialState: any; schema: Record<string, any>; actions: Record<string, any>; subduxes: Record<string, Partial<...>>; reducer: unknown; selectors: Record<...>; }>> }>>) => (state: unknown, action: Action<any>) => unknown> ; onCacheChange: OnCacheOperation<(initialStateState: unknown, mutations: MutationCase[], defaultMutation?: Omit<MutationCase, "matcher">, subduxes: Record<string, Partial<{ actions: Record<string, any> ; initialState: any ; reducer: unknown ; schema: Record<string, any> ; selectors: Record<string, any> ; subduxes: Record<string, Partial<{ initialState: any; schema: Record<string, any>; actions: Record<string, any>; subduxes: Record<string, Partial<...>>; reducer: unknown; selectors: Record<...>; }>> }>>) => (state: unknown, action: Action<any>) => unknown> ; onCacheHit: OnCacheOperation<(initialStateState: unknown, mutations: MutationCase[], defaultMutation?: Omit<MutationCase, "matcher">, subduxes: Record<string, Partial<{ actions: Record<string, any> ; initialState: any ; reducer: unknown ; schema: Record<string, any> ; selectors: Record<string, any> ; subduxes: Record<string, Partial<{ initialState: any; schema: Record<string, any>; actions: Record<string, any>; subduxes: Record<string, Partial<...>>; reducer: unknown; selectors: Record<...>; }>> }>>) => (state: unknown, action: Action<any>) => unknown> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<Moizeable> ; onCacheChange: OnCacheOperation<Moizeable> ; onCacheHit: OnCacheOperation<Moizeable> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & { maxSize: number = 1 }>


memoBuildSchema

memoBuildSchema: Moized<(schema: any, initialState: any, subduxes: {}) => any, Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<(schema: any, initialState: any, subduxes: {}) => any> ; onCacheChange: OnCacheOperation<(schema: any, initialState: any, subduxes: {}) => any> ; onCacheHit: OnCacheOperation<(schema: any, initialState: any, subduxes: {}) => any> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<Moizeable> ; onCacheChange: OnCacheOperation<Moizeable> ; onCacheHit: OnCacheOperation<Moizeable> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & { maxSize: number = 1 }>


memoBuildSelectors

memoBuildSelectors: Moized<(localSelectors: {}, subduxes: {}) => object, Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<(localSelectors: {}, subduxes: {}) => object> ; onCacheChange: OnCacheOperation<(localSelectors: {}, subduxes: {}) => object> ; onCacheHit: OnCacheOperation<(localSelectors: {}, subduxes: {}) => object> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<Moizeable> ; onCacheChange: OnCacheOperation<Moizeable> ; onCacheHit: OnCacheOperation<Moizeable> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & { maxSize: number = 1 }>


memoInitialState

memoInitialState: Moized<(localInitialState: any, subduxes: any) => any, Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<(localInitialState: any, subduxes: any) => any> ; onCacheChange: OnCacheOperation<(localInitialState: any, subduxes: any) => any> ; onCacheHit: OnCacheOperation<(localInitialState: any, subduxes: any) => any> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & Partial<{ isDeepEqual: boolean ; isPromise: boolean ; isReact: boolean ; isSerialized: boolean ; isShallowEqual: boolean ; matchesArg: IsEqual ; matchesKey: IsMatchingKey ; maxAge: number ; maxArgs: number ; maxSize: number ; onCacheAdd: OnCacheOperation<Moizeable> ; onCacheChange: OnCacheOperation<Moizeable> ; onCacheHit: OnCacheOperation<Moizeable> ; onExpire: OnExpire ; profileName: string ; serializer: Serialize ; transformArgs: TransformKey ; updateCacheForKey: UpdateCacheForKey ; updateExpire: boolean }> & { maxSize: number = 1 }>

Accessors

actions

get actions(): DuxActions<D>

Returns

DuxActions<D>


asDux

get asDux(): Object

Returns

Object

Name Type
actions DuxActions<D>
effects any
initialState DuxState<D>
reactions any[]
reducer (state: unknown, action: Action<any>) => unknown
schema any
selectors DuxSelectors<D>
upreducer (action: any) => (state: any) => unknown

effects

get effects(): any

Returns

any


foo

get foo(): DuxActions<D>

Returns

DuxActions<D>


initialState

get initialState(): DuxState<D>

Returns

DuxState<D>


reactions

get reactions(): any[]

Returns

any[]


reducer

get reducer(): (state: unknown, action: Action<any>) => unknown

Returns

fn

▸ (state?, action): unknown

Parameters
Name Type Default value
state unknown initialStateState
action Action<any> undefined
Returns

unknown


schema

get schema(): any

Returns

any


selectors

get selectors(): DuxSelectors<D>

Returns

DuxSelectors<D>


upreducer

get upreducer(): (action: any) => (state: any) => unknown

Returns

fn

▸ (action): (state: any) => unknown

Parameters
Name Type
action any
Returns

fn

▸ (state): unknown

Parameters
Name Type
state any
Returns

unknown

Methods

addDefaultMutation

addDefaultMutation(mutation, terminal?): any

Parameters

Name Type
mutation Mutation<any, DuxState<D>>
terminal? boolean

Returns

any


addEffect

addEffect(actionType, effect): default<D>

Parameters

Name Type
actionType keyof D extends { actions: A } ? { [key in string | number | symbol]: key extends string ? ExpandedAction<A[key], key> : never } : {} | keyof UnionToIntersection<D extends { subduxes: S } ? DuxActions<S[keyof S]> : {}>
effect EffectMiddleware<D>

Returns

default<D>

addEffect(actionCreator, effect): default<D>

Parameters

Name Type
actionCreator Object
actionCreator.match (action: any) => boolean
effect EffectMiddleware<D>

Returns

default<D>

addEffect(guardFunc, effect): default<D>

Parameters

Name Type
guardFunc (action: AnyAction) => boolean
effect EffectMiddleware<D>

Returns

default<D>

addEffect(effect): default<D>

Parameters

Name Type
effect EffectMiddleware<D>

Returns

default<D>


addMutation

addMutation<A>(matcher, mutation, terminal?): default<D>

Type parameters

Name Type
A extends string | number | symbol

Parameters

Name Type
matcher A
mutation Mutation<DuxActions<D>[A] extends (...args: any) => P ? P : never, DuxState<D>>
terminal? boolean

Returns

default<D>

addMutation<A>(matcher, mutation, terminal?): default<D>

Type parameters

Name Type
A extends Action<any, A>

Parameters

Name Type
matcher (action: A) => boolean
mutation Mutation<A, DuxState<D>>
terminal? boolean

Returns

default<D>

addMutation<A>(actionCreator, mutation, terminal?): default<D>

Type parameters

Name Type
A extends ActionCreator<any, any[], A>

Parameters

Name Type
actionCreator A
mutation Mutation<ReturnType<A>, DuxState<D>>
terminal? boolean

Returns

default<D>


addReaction

addReaction(reaction): void

Parameters

Name Type
reaction any

Returns

void


createStore

createStore(options?): ToolkitStore<D extends { initialState: INITIAL_STATE } ? INITIAL_STATE : {} & D extends { subduxes: any } ? SubduxesState<D> : unknown & {}, AnyAction, Middlewares<DuxState<D>>> & MiddlewareAPI<Dispatch<AnyAction>, DuxState<D>> & { actions: DuxActions<D> ; dispatch: DuxActions<D> ; getState: CurriedSelectors<DuxSelectors<D>> ; selectors: DuxSelectors<D> }

Parameters

Name Type
options Partial<{ buildMiddleware: (middleware: any[]) => any ; preloadedState: DuxState<D> ; validate: boolean }>

Returns

ToolkitStore<D extends { initialState: INITIAL_STATE } ? INITIAL_STATE : {} & D extends { subduxes: any } ? SubduxesState<D> : unknown & {}, AnyAction, Middlewares<DuxState<D>>> & MiddlewareAPI<Dispatch<AnyAction>, DuxState<D>> & { actions: DuxActions<D> ; dispatch: DuxActions<D> ; getState: CurriedSelectors<DuxSelectors<D>> ; selectors: DuxSelectors<D> }


toDux

toDux(): Object

Returns

Object

Name Type
actions DuxActions<D>
effects any
initialState DuxState<D>
reactions any[]
reducer (state: unknown, action: Action<any>) => unknown
schema any
selectors DuxSelectors<D>
upreducer (action: any) => (state: any) => unknown