From 325ad47731d5283f269f8454cfe812a13eac41f4 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Thu, 25 Aug 2022 17:52:13 -0400 Subject: [PATCH] getting the upreducer right --- src/Updux.ts | 8 ++++++-- src/reducer.test.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Updux.ts b/src/Updux.ts index 0ef2c32..207a37d 100644 --- a/src/Updux.ts +++ b/src/Updux.ts @@ -33,7 +33,11 @@ export class Updux< ); } - get reducer() { - return (...args) => R.purry((state : DuxAggregateState, _action : any) => state, args); + get reducer(): ( state: DuxAggregateState, action: Action ) => DuxAggregateState { + return (state,action) => this.upreducer(action)(state); + } + + get upreducer(): (action: Action) => (state: DuxAggregateState) => DuxAggregateState { + return (action) => state => state; } } diff --git a/src/reducer.test.ts b/src/reducer.test.ts index 3babb7d..c668a1e 100644 --- a/src/reducer.test.ts +++ b/src/reducer.test.ts @@ -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 });