This commit is contained in:
Yanick Champoux 2022-08-25 16:44:19 -04:00
parent 4d4a5dde50
commit 9772ce4bec

View File

@ -25,17 +25,6 @@ export type DuxStateSubduxes<C extends {}> = keyof C extends never
? unknown
: { [K in keyof C]: StateOf<C[K]> };
// type UnionArrayTypes<A extends any[]> = A[number];
// type ActionType<A extends ActionGenerator> = A extends ActionGenerator<infer B> ? B : never;
// type ActionAsObject<A extends ActionGenerator> = Record< ActionType<A>, A > }>;
// type UnionToIntersection<U> =
// (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never
// type ActionsAsObject<A extends ActionGenerator[]> = ActionAsObject< A[number]>
export class Updux<TState extends any = {}, TActions extends { [key: string]: ActionGenerator } = {}, TSubduxes = {}> {
#localInitial: any = {};
#subduxes;
@ -52,10 +41,6 @@ export class Updux<TState extends any = {}, TActions extends { [key: string]: Ac
return this.#actions;
}
get action(): ActionsAsObject<TActions> {
return Object.fromEntries(this.#actions.map( a => [ a.type, a ] ));
}
get initial(): TState & DuxStateSubduxes<TSubduxes> {
if (Object.keys(this.#subduxes).length === 0) return this.#localInitial;