add reducer

This commit is contained in:
Yanick Champoux 2022-08-25 11:51:53 -04:00
parent 3c78f34d5b
commit 46b0565819
2 changed files with 15 additions and 0 deletions

View File

@ -50,4 +50,8 @@ export class Updux<TState extends any = {}, TActions extends { [key: string]: Ac
R.mapValues(this.#subduxes, ({ initial }) => initial),
);
}
get reducer() {
return (state, action) => state;
}
}

11
src/reducer.test.ts Normal file
View File

@ -0,0 +1,11 @@
import { test, expect } from 'vitest';
import { Updux } from './Updux.js';
test('basic reducer', () => {
const dux = new Updux({});
expect(dux.reducer).toBeTypeOf('function');
expect(dux.reducer({ a: 1 }, { type: 'foo' })).toMatchObject({ a: 1 }); // noop
});