Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Last active May 29, 2019 20:57
Show Gist options
  • Save bradfordlemley/c95bf167a6736d14fa7e41f939cdfca5 to your computer and use it in GitHub Desktop.
Save bradfordlemley/c95bf167a6736d14fa7e41f939cdfca5 to your computer and use it in GitHub Desktop.
Vanilla todo library
function createTodoLib() {
let todos = [];
let isFetching = false;
return {
get todos() {return todos},
get isFetching() {return isFetching},
addTodo(title) {
todos = todos.concat({title});
},
async fetchTodos() {
isFetching = true;
const newTodos = await fetchFromCloud();
todos = todos.concat(newTodos);
isFetching = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment