instantdb/instant

[Request] Guide on how to optimize for optimistic updates

Opened this issue · 0 comments

Hi all! I'm having fun writing a project with this, but I'm struggling with a key thing. I would like to have my React Native app be local first, as occasionally I'm in areas where I do not have any network or spotty network at best and I would like my changes to be persisted locally first.

I've thought of multiple approaches and - because it's my first time using Instant - I'm also well aware I might not be doing things correctly. Which is why I'm hoping on some insights and guidance from y'all that might benefit any Instant user in how to tackle ensuring updates are optimistic and local first.

For context my project specifically appears to struggle when separating queries into hooks, and it relies on entries being ordered as well.
I know there's a separate issue for custom ordered queries so currently I stick to order: { serverCreatedAt: 'desc' } but that also appears to be quite expensive and not very optimistic especially when there is a working network connection. Do I just fetch all and write a filter myself, or have a {archived, completed, ...} property in there somewhere (which in my experience also impacted a mutation's optimistic-ness).

All in all I'm hoping to learn from y'all how to best write my applications using Instant 🙏