I have a reason to want to use a getter in my list of properties. It would be nice to be able to suppress the warnings that result: "The property X is computed and will not persist:"
My use case:
I have a private property that basically tracks the result of a computed, and I want to persist that property. When the store is hydrated, I use this property to decide whether some other initialization needs to occur. I don't want this property to be Observable.
The property's value is assigned when the related getter is called:
get X () {
this._X = compute something based on the other store vars
return this._X
}
I found that in some cases this._X is recalculated by the getter, but not persisted. If I add both _X and X to the list of properties in makePersistible() then everything works the way I want it to. When the getter is called mobx-persist sees the change and then triggers a save.
I have a reason to want to use a getter in my list of properties. It would be nice to be able to suppress the warnings that result: "The property X is computed and will not persist:"
My use case: I have a private property that basically tracks the result of a computed, and I want to persist that property. When the store is hydrated, I use this property to decide whether some other initialization needs to occur. I don't want this property to be Observable.
The property's value is assigned when the related getter is called:
I found that in some cases this._X is recalculated by the getter, but not persisted. If I add both
_X
andX
to the list of properties in makePersistible() then everything works the way I want it to. When the getter is called mobx-persist sees the change and then triggers a save.