mobx-persist
mobx-persist copied to clipboard
Is it possible to define custom storage keys for @observable properties?
Hi,
In the example of readme, one can persist in this way:
class SomeItem { @persist @observable name = 'some' }
This is nice and straightforward, but causes problems if I want to refactor a property name (e.g. if I want to rename observable from 'name' to 'firstName'.
If I do that renaming, the value persisted in 'name' will be lost.
Ideally to get around this, I would like to have the possibility to optionally define a storage key, something similar to this:
class SomeItem { @persist('MY_CUSTOM_KEY_THAT_DOES_NOT_CHANGE') @observable name = 'some' }
Is this possible to achieve?
Same situation, I want to rename the variable name and I am losing all the data.