updux/types/index.d.ts

64 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-10-12 18:49:08 +00:00
type Dict<T> = Record<string, T>;
2021-10-12 17:11:32 +00:00
2021-10-12 18:49:08 +00:00
declare module 'updux' {
/**
* Configuration object typically passed to the constructor of the class Updux.
*/
export interface UpduxConfig<TState = unknown> {
/**
* Local initial state.
* @default {}
*/
initial?: TState;
2021-10-12 17:11:32 +00:00
2021-10-12 18:49:08 +00:00
/**
* Subduxes to be merged to this dux.
*/
subduxes?: Dict<Updux|UpduxConfig>;
2021-10-12 17:11:32 +00:00
2021-10-12 18:49:08 +00:00
/**
* Local actions.
*/
actions?: Record<string, any>;
2021-10-12 17:11:32 +00:00
2021-10-12 18:49:08 +00:00
/**
* Local selectors.
*/
selectors?: Record<string, Function>;
/**
* Local mutations
*/
mutations?: Record<string, Function>;
/**
* Selectors to apply to the mapped subduxes. Only
* applicable if the dux is a mapping dux.
*/
mappedSelectors?: Record<string, Function>;
/**
* Local effects.
*/
effects?: Record<string, Function>;
/**
* Local reactions.
*/
reactions?: Record<string, Function>;
/**
* If true, enables mapped reactions. Additionally, it can be
* a reaction function, which will treated as a regular
* reaction for the mapped dux.
*/
mappedReaction?: Function | boolean;
}
export class Updux<TState = unknown> {
constructor(config: Partial<UpduxConfig<TState>>);
get initial(): TState;
get selectors(): unknown;
}
2021-10-12 17:11:32 +00:00
}