Says I have a todo list, after a todo is created I want to save the item into localstorage. How would the reducer look like? Should I do the setItem method in reducer or in the view?
case 'PUBLISH_TODO_PENDING':
return { ...state, loading: true, todo_published: false, //do I do this? }
case 'PUBLISH_TODO_FULFILLED':
return {
...state,
loading: false,
todo_published: true, //do I do this?
data: {
result: {
todo: state.data.todo,
}
}
}
If I want to use setItem in view the I have to do a flag telling the stat of the todo wether is published or not. It's silly I have to put the flag in initial state too.