getting the upreducer right

This commit is contained in:
Yanick Champoux 2022-08-25 17:52:13 -04:00
parent b96f5e72ac
commit 325ad47731
2 changed files with 8 additions and 4 deletions

View File

@ -33,7 +33,11 @@ export class Updux<
); );
} }
get reducer() { get reducer(): ( state: DuxAggregateState<TState,TSubduxes>, action: Action ) => DuxAggregateState<TState,TSubduxes> {
return (...args) => R.purry((state : DuxAggregateState<TState,TSubduxes>, _action : any) => state, args); return (state,action) => this.upreducer(action)(state);
}
get upreducer(): (action: Action) => (state: DuxAggregateState<TState,TSubduxes>) => DuxAggregateState<TState,TSubduxes> {
return (action) => state => state;
} }
} }

View File

@ -13,7 +13,7 @@ test('basic reducer', () => {
test('basic upreducer', () => { test('basic upreducer', () => {
const dux = new Updux({ initial: {a: 3} }); const dux = new Updux({ initial: {a: 3} });
expect(dux.reducer).toBeTypeOf('function'); expect(dux.upreducer).toBeTypeOf('function');
expect(dux.reducer({ type: 'foo' })({a:1})).toMatchObject({ a: 1 }); // noop expect(dux.upreducer({ type: 'foo' })({a:1})).toMatchObject({ a: 1 }); // noop
}); });