Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Created September 21, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/e94a6e47a50d63eb6b2ff1a2508b7aec to your computer and use it in GitHub Desktop.
Save NetanelBasal/e94a6e47a50d63eb6b2ff1a2508b7aec to your computer and use it in GitHub Desktop.
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