Last active
September 29, 2017 19:01
-
-
Save danielbischoff/522e2bd5f6c495d05e31e0ebf015c79c 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
class TodoApi { | |
fetchTodos = () => request.get('/todos') | |
} | |
class TodoStore { | |
@observable todos = []; | |
constructor(todoApi) { | |
this.todoApi = todoApi; | |
} | |
fetchTodos = async () => { | |
const todos = await this.todoApi.fetchTodos(); | |
runInAction(() => { | |
this.todos = todos; | |
}); | |
} | |
} | |
// Then in your main | |
const todoApi = new TodoApi(); | |
const todoStore = new TodoStore(todoApi); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment