Skip to content

Instantly share code, notes, and snippets.

@perjo927
Last active September 9, 2020 05:37
Show Gist options
  • Save perjo927/f093c5a67d3966e8f3c9c1a6fb3d7ea0 to your computer and use it in GitHub Desktop.
Save perjo927/f093c5a67d3966e8f3c9c1a6fb3d7ea0 to your computer and use it in GitHub Desktop.
Todo App Actions
export const CONSTS = {
actions: {
ADD: "ADD",
DELETE: "DELETE",
UNDO: "UNDO",
REDO: "REDO",
TOGGLE: "TOGGLE",
SET_VISIBILITY: "SET_VISIBILITY",
},
visibilityFilters: {
ALL: "ALL",
DONE: "DONE",
IN_PROGRESS: "IN_PROGRESS",
},
};
export const actions = {
addTodo: (todo) => ({
type: CONSTS.actions.ADD,
value: todo,
}),
deleteTodo: (id) => ({
type: CONSTS.actions.DELETE,
value: id,
}),
toggleTodo: (id) => ({
type: CONSTS.actions.TOGGLE,
value: id,
}),
undo: () => ({
type: CONSTS.actions.UNDO,
value: null,
}),
redo: () => ({
type: CONSTS.actions.REDO,
value: null,
}),
setVisibility: (filter) => ({
type: CONSTS.actions.SET_VISIBILITY,
value: filter,
}),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment