mst-gql icon indicating copy to clipboard operation
mst-gql copied to clipboard

mst-gql check if the store ready after rehydration

Open ryskin opened this issue 2 years ago • 9 comments

The frequent task is to render App when the store is ready and rehydrated but the problem is that I can find out when the store is ready but I can't find out when localStorageMixin finish work and the store is ready, for example, to check if a user is logged in to push him to match screen.

I see only two ways, one way I don't like is to make delay and another way is to create custom localStorageMixin that in the end change the property of model "ready" to true.

Would be great to have something like this resolved without the patch. I don't know how other but I meet this problem every project.

If you have a better way to resolve this issue so please let me know.

ryskin avatar Nov 04 '21 01:11 ryskin

@chrisdrackett @dpnolte @elie222 @zenflow @RXminuS @rdewolff it is really needed feature

rasfront avatar Nov 04 '21 09:11 rasfront

No need to mention all of us @Raserad

rdewolff avatar Nov 04 '21 10:11 rdewolff

No need to mention all of us @Raserad

Sorry

rasfront avatar Nov 04 '21 12:11 rasfront

While I agree that it is not nice to mention everyone on your mind if you don't get a response immediately, I guess it is also a sign that there is not too much going on with mst-gql lately. It seems practically dead: no new releases, no answers to issues, no discussion, and a PR (#346) pending for weeks. How do you see the status of the project @jesse-savary?

beepsoft avatar Nov 23 '21 15:11 beepsoft

If you have a better way to resolve this issue so please let me know.

I am using https://www.npmjs.com/package/mst-persist which returns a promise resolved after rehydrating the store.

smokku avatar Nov 23 '21 16:11 smokku

@smokku Just curious..how is the performance with mst-persist since there is no throttling. It would seem like persisting to the store on every onSnapshot call would be a serious performance hit on your Rootstore.

Just curious what you were experiencing on that front.

Aryk avatar Dec 19 '21 08:12 Aryk

I am whitelisting a small subset of store, so this is not an issue for me.

BTW, I am not sure how such throttling could work without potential for data loss.

smokku avatar Dec 19 '21 12:12 smokku

Agreed, ultimately is there any point to whitelisting anything other then the calls themselves (__queryCache), which is the first thing I'm going to try.

I'm still going to implement a purging strategy tied to app versions so that I can fix issues if Im caching bad data.


Quick Update:

I could not figure out a purging strategy that works. Ultimately you want to load results from net http calls (aka the queryCache), but I found if i rehydrate only that, I get other errors which is really strange. If I store the whole thing, then the initial call to update the snapshot can take 1.5 to 2 seconds which is too long on app bootup.

Anyways...not sure if this juice is worth the squeeze but would be curious to hear how others did it and if it actually makes a noticeable impact on your app.

Aryk avatar Dec 19 '21 17:12 Aryk

Will see if I can come up with something as AFAIK we encountered this issue with our app.

@Raserad in the future try pinging me :)

jesse-savary avatar Mar 21 '22 18:03 jesse-savary