Created
September 21, 2018 14:31
-
-
Save NetanelBasal/e94a6e47a50d63eb6b2ff1a2508b7aec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class TodosService { | |
constructor(private todosStore: TodosStore) {} | |
updateFilter(filter: VISIBILITY_FILTER) { | |
this.todosStore.updateRoot({ | |
ui: { | |
filter | |
} | |
}); | |
} | |
complete(id: ID) { | |
todosStore.update(id, entity => ({ completed: !entity.completed })); | |
} | |
add(text: string) { | |
const todo = createTodo(text); | |
this.todosStore.add(todo); | |
} | |
delete(id: ID) { | |
this.todosStore.remove(id); | |
} | |
} | |
export const todosService = new TodosService(todosStore); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment