This commit is contained in:
Yanick Champoux 2019-10-23 14:44:12 -04:00
parent 0949200bac
commit 76a75c9120
2 changed files with 12 additions and 2 deletions

View File

@ -9,8 +9,15 @@ export type Dictionary<T> = { [key: string]: T };
export type Mutation<S=any> = (payload: any, action: Action) => (state: S) => S ; export type Mutation<S=any> = (payload: any, action: Action) => (state: S) => S ;
type ActionPayloadGenerator = (...args:any[]) => any;
export type ActionCreator = (...args: any[] ) => Action; export type ActionCreator = (...args: any[] ) => Action;
export type UpduxConfig = Partial<{ export type UpduxConfig = Partial<{
subduxes: {} subduxes: {},
actions: {
[ type: string ]: ActionPayloadGenerator
},
mutations: any,
effects: any,
}>; }>;

View File

@ -6,12 +6,15 @@ import buildMutations from './buildMutations';
import buildCreateStore from './buildCreateStore'; import buildCreateStore from './buildCreateStore';
import buildMiddleware from './buildMiddleware'; import buildMiddleware from './buildMiddleware';
import buildUpreducer from './buildUpreducer'; import buildUpreducer from './buildUpreducer';
import { UpduxConfig, Dictionary } from './types'; import { UpduxConfig, Dictionary, Action, ActionCreator } from './types';
export class Updux { export class Updux {
subduxes: Dictionary<Updux>; subduxes: Dictionary<Updux>;
actions: Dictionary<ActionCreator>
constructor(config: UpduxConfig) { constructor(config: UpduxConfig) {
this.subduxes = fp.mapValues( this.subduxes = fp.mapValues(