188
rated 0 times
[
195]
[
7]
/ answers: 1 / hits: 17552
/ 8 Years ago, sun, september 4, 2016, 12:00:00
Given a MyQuestionStore
store:
class MyQuestionStore {
@observable asked = 'today';
@observable answered = false;
@observable question = {
upvotes: 0,
body: null,
asker: null,
askerPoints: null,
askerBadges: null
}
// some more initial state observables...
// some actions below...
}
const myQuestionStore = new MyQuestionStore();
export default myQuestionStore;
What would be the correct way to reset all store observables back to their initial states data ('today'/false/0/null/etc..)?
NOTE: Something like MyQuestionStore.reset()
for example I think would be a good MobX way, but I don't think it exists. I would have to write an action called reset
and manually reset each observable back to its initial state. I don't think that would be the right way, since if I add more observables
, I would have to manually add them to the reset
action every time.
More From » mobx