You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
499 B
26 lines
499 B
import {ADD, REMOVE} from "@/store/constant/todo"
|
|
import {combineReducers} from "redux";
|
|
|
|
let initData: ITodo[] = []
|
|
|
|
const todos = (state = initData, action: IAction) => {
|
|
switch (action.type) {
|
|
case ADD:
|
|
return [
|
|
...state,
|
|
{
|
|
id: action.id,
|
|
text: action.text
|
|
}
|
|
]
|
|
case REMOVE:
|
|
const list = state.filter(v => v.id != action.id)
|
|
return [
|
|
...list
|
|
]
|
|
default:
|
|
return state
|
|
}
|
|
}
|
|
|
|
export default todos;
|
|
|