Closed schumannd closed 6 years ago
I'm confused. Looking at the example code it seems more like The key of your datastore
is actually an arbitrary name that is used to store all the persisted properties of the given store, not just the one that matches the specified key.
I think your correction is incorrect. I've been trying to setup persistence on my store by following the doc and had duplicates.
It seems like hydrate('s', myStore)
persists the whole store at the localStorage key s
, not only the s
observable.
If you look at the examples, it is used that way: hydrate('appState', AppState)
, with 'appState'
being an arbitrary key that is not the name of an observable, and AppState
being the instantiated store object.
@pinqy520 If I'm not mistaken, this should be reverted.
@rgehan You are right, I have fixed the README...
I am always in favor of examples. But I wish there was some better naming. E.g.
What does
'some'
inhydrate('some', someStore)
mean or do? In the documentation it is referred to as
The key of your datastore
. But where is this key initially set?I thought I understood this package until stuff started breaking and I'm starting over again. If someone explains the usage of
@persist
andhydrate()
I'll rewrite the readme to be more understandable.Edit:
If I understand correctly, the example is broken and
hydrate('some', someStore)
does not hydrate anything as there is no datastore key with that name. I will open a PR that fixes this