index wip

This commit is contained in:
Yanick Champoux 2019-10-23 13:48:19 -04:00
parent 125800a8b9
commit 0949200bac
2 changed files with 7 additions and 3 deletions

View File

@ -12,4 +12,5 @@ export type Mutation<S=any> = (payload: any, action: Action) => (state: S) => S
export type ActionCreator = (...args: any[] ) => Action;
export type UpduxConfig = Partial<{
subduxes: {}
}>;

View File

@ -6,14 +6,17 @@ import buildMutations from './buildMutations';
import buildCreateStore from './buildCreateStore';
import buildMiddleware from './buildMiddleware';
import buildUpreducer from './buildUpreducer';
import { UpduxConfig, Dictionary } from './types';
export class Updux {
constructor(config) {
subduxes: Dictionary<Updux>;
constructor(config: UpduxConfig) {
this.subduxes = fp.mapValues(
value => fp.isPlainObject(value) ? new Updux(value ) : value )(fp.getOr({},'subduxes',config)
);
(value:UpduxConfig|Updux) => fp.isPlainObject(value) ? new Updux(value) : value )(fp.getOr({},'subduxes',config)
) as Dictionary<Updux>;
this.actions = buildActions(