Skip to content

Instantly share code, notes, and snippets.

@httnn
Created January 19, 2017 12:34
Show Gist options
  • Save httnn/ec41705268ed6d7bc9ad1bfcabc39e64 to your computer and use it in GitHub Desktop.
Save httnn/ec41705268ed6d7bc9ad1bfcabc39e64 to your computer and use it in GitHub Desktop.
MobX: pattern for updating data when other data changes?
class Store {
constructor() {
reaction(
() => [this.filter, this.limit, this.order],
() => this.getItems()
);
this.getItems();
}
@observable filter = '';
@observable order = '';
@observable limit = '';
@observable items = [];
@action async getItems() {
const items = await api.getItems(this.filter, this.order, this.limit);
this.items = items;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment