Skip to content

Instantly share code, notes, and snippets.

@danielbischoff
Last active September 29, 2017 19:01
Show Gist options
  • Save danielbischoff/522e2bd5f6c495d05e31e0ebf015c79c to your computer and use it in GitHub Desktop.
Save danielbischoff/522e2bd5f6c495d05e31e0ebf015c79c to your computer and use it in GitHub Desktop.
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