getting the upreducer right
This commit is contained in:
parent
b96f5e72ac
commit
325ad47731
@ -33,7 +33,11 @@ export class Updux<
|
||||
);
|
||||
}
|
||||
|
||||
get reducer() {
|
||||
return (...args) => R.purry((state : DuxAggregateState<TState,TSubduxes>, _action : any) => state, args);
|
||||
get reducer(): ( state: DuxAggregateState<TState,TSubduxes>, action: Action ) => DuxAggregateState<TState,TSubduxes> {
|
||||
return (state,action) => this.upreducer(action)(state);
|
||||
}
|
||||
|
||||
get upreducer(): (action: Action) => (state: DuxAggregateState<TState,TSubduxes>) => DuxAggregateState<TState,TSubduxes> {
|
||||
return (action) => state => state;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ test('basic reducer', () => {
|
||||
test('basic upreducer', () => {
|
||||
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
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user