Advertisement
cbigot

Untitled

Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const addTodo = (todoContent: string) => {
  2.  
  3.     const newTodo: Todo = {
  4.         _id: 'todo_' + new Date().getTime(),
  5.         content: todoContent,
  6.         status: CodeStatus.TODO
  7.     };
  8.  
  9.     return (dispatch: Function) => {
  10.         // On appelle notre fonction de sauvegarde
  11.         return saveTodo(fromJS(newTodo)).then(reponse => {
  12.             // On notifie notre store avec une action d'ajout
  13.             dispatch({
  14.                 type: Action.ADD_TODO,
  15.                 todo: fromJS(newTodo)
  16.             });
  17.         });
  18.     };
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement