updux/dist/tutorial/todoList.js

32 lines
860 B
JavaScript

import Updux from '../index.js';
import nextIdDux from './nextId.js';
import todosDux from './todos.js';
export default new Updux({
subduxes: {
todos: todosDux,
nextId: nextIdDux,
},
actions: {
addTodo: (description) => description,
},
}).addEffect('addTodo', ({ getState, dispatch }) => (next) => (action) => {
const id = getState.getNextId();
dispatch.incNextId();
next(action);
dispatch.addTodoWithId(action.payload, id);
});
const x = new Updux({
subduxes: {
todos: todosDux,
nextId: nextIdDux,
},
actions: {
addTodo: (description) => description,
},
}).addEffect('addTodo', ({ getState, dispatch }) => (next) => (action) => {
const id = getState.getNextId();
dispatch.incNextId();
next(action);
dispatch.addTodoWithId(action.payload, id);
});