glorious noop
This commit is contained in:
parent
46b0565819
commit
c609a19ef8
@ -25,6 +25,8 @@ export type DuxStateSubduxes<C extends {}> = keyof C extends never
|
||||
? unknown
|
||||
: { [K in keyof C]: StateOf<C[K]> };
|
||||
|
||||
type DuxAggregateState<TState,TSubduxes> = TState & DuxStateSubduxes<TSubduxes> ;
|
||||
|
||||
export class Updux<TState extends any = {}, TActions extends { [key: string]: ActionGenerator } = {}, TSubduxes = {}> {
|
||||
#localInitial: any = {};
|
||||
#subduxes;
|
||||
@ -41,7 +43,7 @@ export class Updux<TState extends any = {}, TActions extends { [key: string]: Ac
|
||||
return this.#actions;
|
||||
}
|
||||
|
||||
get initial(): TState & DuxStateSubduxes<TSubduxes> {
|
||||
get initial(): DuxAggregateState<TState,TSubduxes>{
|
||||
if (Object.keys(this.#subduxes).length === 0) return this.#localInitial;
|
||||
|
||||
return Object.assign(
|
||||
@ -52,6 +54,6 @@ export class Updux<TState extends any = {}, TActions extends { [key: string]: Ac
|
||||
}
|
||||
|
||||
get reducer() {
|
||||
return (state, action) => state;
|
||||
return (state : DuxAggregateState<TState,TSubduxes>, _action : any) => state;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { test, expect } from 'vitest';
|
||||
import { Updux } from './Updux.js';
|
||||
|
||||
test('basic reducer', () => {
|
||||
const dux = new Updux({});
|
||||
const dux = new Updux({ initial: {a: 3} });
|
||||
|
||||
expect(dux.reducer).toBeTypeOf('function');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user