quarrant / mobx-persist-store

Persist and rehydrate observable properties in mobx store.
268 stars 14 forks source link

[Feature]Option to disable console warning messages #84

Closed corinnaSchultz closed 1 year ago

corinnaSchultz commented 2 years ago

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.

codeBelt commented 2 years ago

Can you create a codesandbox example so we can see the issue.

corinnaSchultz commented 1 year ago

I found a better design for my original issue, so this request can be disregarded.