You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have store where I store if some section in the UI is collapsed. It is and object indexed by id of the section. When I save these like this (for initial fetch), persistance works:
classUiStore{closedSections={};toggleSection=(sectionId: string,newState?: boolean)=>{if(newState===false){// This works I have to get old sections and resave entire object againconstoldSections=toJS(this.closedSections)||{};this.closedSections={ ...oldSections,[sectionId]: true};}else{remove(this.closedSections,sectionId);}};}decorate(UiStore,{closedSections: [persist('object'),observable],isClosed: observable,toggleSection: action,clearDataAfterLogout: action,});exportdefaultnewUiStore();
but that is too tedious, I would prefer to use set mobx method. But that does not seems to work (see example below).
classUiStore{closedSections={};toggleSection=(sectionId: string,newState?: boolean)=>{if(newState===false){// This does not work after rehdyratation closedSections is empty objectset(this.closedSections,sectionId,true);}else{remove(this.closedSections,sectionId);}};}decorate(UiStore,{closedSections: [persist('object'),observable],isClosed: observable,toggleSection: action,clearDataAfterLogout: action,});exportdefaultnewUiStore();
Any idea how to do it? Readme is not very clear about this. I also did not found any answer in the issues.
Thanks for help.
The text was updated successfully, but these errors were encountered:
Hi,
I have store where I store if some section in the UI is collapsed. It is and object indexed by id of the section. When I save these like this (for initial fetch), persistance works:
but that is too tedious, I would prefer to use
set
mobx method. But that does not seems to work (see example below).Any idea how to do it? Readme is not very clear about this. I also did not found any answer in the issues.
Thanks for help.
The text was updated successfully, but these errors were encountered: