Created
January 19, 2017 12:34
-
-
Save httnn/ec41705268ed6d7bc9ad1bfcabc39e64 to your computer and use it in GitHub Desktop.
MobX: pattern for updating data when other data changes?
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 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