This commit is contained in:
Yanick Champoux 2021-09-29 09:40:02 -04:00
parent fd064f5996
commit 0870767994
2 changed files with 16 additions and 5 deletions

View File

@ -37,6 +37,10 @@ export class Updux {
return this.#memoActions(this.#actions, this.#subduxes);
}
get selectors() {
return {};
}
addAction(type, payloadFunc) {
const theAction = action(type,payloadFunc);
@ -44,4 +48,8 @@ export class Updux {
return theAction;
}
addSelector(name, func) {
return;
}
}

View File

@ -59,7 +59,10 @@ test('addAction', async(t) => {
test('basic selectors', async(t) => {
const alpha = new Updux({
initial: { quux: 3 },
}).addSelector('getQuux', ({ quux }) => quux);
selectors: {
getQuux: ({quux}) => quux
}
});
const dux = new Updux({
initial: {
@ -70,10 +73,10 @@ test('basic selectors', async(t) => {
selectors: {
getBar: ({ bar }) => bar,
},
})
.addSelector('getFoo', (state) => state.foo)
.addSelector('getAdd', ({ foo }) => (add) => add + foo)
.addAction('stuff');
});
dux.addSelector('getFoo', (state) => state.foo)
dux.addSelector('getAdd', ({ foo }) => (add) => add + foo)
dux.addAction('stuff');
t.equal(dux.selectors.getBar({ bar: 3 }), 3);
t.equal(dux.selectors.getFoo({ foo: 3 }) , 3);