UNPKG

simred

Version:

A simple redux-like application state manager

26 lines (24 loc) 536 B
import { withInitialState } from 'simred' const INITIAL_STATE = { editing: null, editText: '' } export const TodoEditReducer = withInitialState(INITIAL_STATE)({ editTodo: (_state, actions) => (todo) => { if (todo) { actions.todoEdit.updateEditTodo(todo.title) return { editing: todo.id, // editText: todo.title } } else { return INITIAL_STATE } }, updateEditTodo: (state) => (editText) => { return { ...state, editText } } } )