meteorrn / meteor-react-native

Meteor client for React Native matching Meteor Spec
https://guide.meteor.com/react-native.html
Other
59 stars 31 forks source link

only remove stale documents an a connect, and skipUpdate for the tracker hook #124

Closed bratelefant closed 11 months ago

bratelefant commented 1 year ago

If there's a (re)connect, then all docs are removed completely and then readded via initial ddp added events. This can result in flashing ui, since items disappear and then reappear after being readded.

I guess this was considered necessary, since during the time with no connection to the server, there may be docs that get removed from the db, and the somehow the client needs to get those docs removed aswell as soon as it is reconnected.

This PR solves this by marking all docs as _stale on a disconnect. After a reconnect, docs will get initially added via ddp, and will be flagged as not being _stale anymore.

After a certain timeout following a (re)connect (bet there's a better place to do this? if all subs are ready maybe?), all docs, that were removed on the server are still flagged as _stale. Now all _stale docs can be safely removed from the client.

Also adds the skipUpdate callback to the useTracker hook, as known from react-meteor-data.

jankapunkt commented 1 year ago

@bratelefant is there something I can do here to help out?

bratelefant commented 1 year ago

Actually I'm really not sure weather this is a feature / behavior that is really requested or accepted. That's why I added this as a draft, as sort of a basis for discussion.

bratelefant commented 1 year ago

Also, I suppose we need a better way to determine the point when the initial additions of documents are finished to remove stale data; usage of setTimeout is kind of messy.

github-actions[bot] commented 11 months ago

Closing this PR due to no activity. Feel free to reopen.