Last active
May 29, 2019 20:57
-
-
Save bradfordlemley/c95bf167a6736d14fa7e41f939cdfca5 to your computer and use it in GitHub Desktop.
Vanilla todo library
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
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