import { operations } from '@fleur/fleur' ; import { TodoActions } from './actions' ; import { getTodos } from './api' ; export const TodoOps = operations ( { async fetchTodos ( context ) { const todos = await getTodos ( ) ; context . dispatch ( TodoActions . restoreTodos , todos ) ; } , addTodo ( context , payload ) { context . dispatch ( TodoActions . addTodo , payload ) ; } , updateTodoTitle ( context , payload ) { context . dispatch ( TodoActions . patch , payload ) ; } , destroyTodo ( context , payload ) { context . dispatch ( TodoActions . destroy , payload ) ; } , toggleTodo ( context , payload ) { context . dispatch ( TodoActions . toggle , payload ) ; } , toggleAllTodo ( context , payload ) { context . dispatch ( TodoActions . toggleAll , payload ) ; } , clearCompleted ( context ) { context . dispatch ( TodoActions . clearCompleted , { } ) ; } , } ) ;