28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
import Updux from '../index.js';
|
|
import u from '@yanick/updeep-remeda';
|
|
import todoDux from './todo.js';
|
|
export default new Updux({
|
|
initialState: [],
|
|
actions: {
|
|
addTodoWithId: (description, id) => ({ description, id }),
|
|
todoDone: (id) => id,
|
|
},
|
|
findSelectors: {
|
|
getTodoById: (state) => (id) => state.find(u.matches({ id })),
|
|
},
|
|
})
|
|
.addMutation('addTodoWithId', (todo) => (todos) => todos.concat(Object.assign(Object.assign({}, todo), { done: false })))
|
|
.addMutation('todoDone', (id, action) => u.map(u.if(u.matches({ id }), todoDux.upreducer(action))));
|
|
const x = new Updux({
|
|
initialState: [],
|
|
actions: {
|
|
addTodoWithId: (description, id) => ({ description, id }),
|
|
todoDone: (id) => id,
|
|
},
|
|
findSelectors: {
|
|
getTodoById: (state) => (id) => state.find(u.matches({ id })),
|
|
},
|
|
})
|
|
.addMutation('addTodoWithId', (todo) => (todos) => todos.concat(Object.assign(Object.assign({}, todo), { done: false })))
|
|
.addMutation('todoDone', (id, action) => u.map(u.if(u.matches({ id }), todoDux.upreducer(action))));
|