Open codeBelt opened 2 years ago
I didn’t think about this case before, but in your example it seems like a good idea)
Honestly, preventInitialHydration
looks like something hard for understanding (maybe I mistake here) and I offer you other name - autoHidrate
I like the name autoHydrate
. I will probably work on a PR this weekend and you can see what I come up with. First I think I am going to write more tests so I don't mess things up.
I am going to work on this still but it will be a few weeks now until I can.
Has this problem been solved?
I think there might be situation where you don't want the observable to hydrate right away when
makePersistable
is called.For example in my application the user can send another user a url with query params so the page will be configured from the query params and not the persisted data.
We could determine if there is query params and wrap
makePersistable
in aif
statement like this:But what if we had more control over when the observable gets hydrated. What if we allowed a property (
preventInitialHydration
) to be set somakePersistable
does not automatically hydrate the observable. Then we can callhydrateStore
later on if needed.preventInitialHydration
?