marceljuenemann / rxdb-supabase

Offline support for Supabase using RxDB
MIT License
135 stars 5 forks source link

Support for a push-only mode #5

Open marceljuenemann opened 1 year ago

marceljuenemann commented 1 year ago

Instead of a true offline-first paradigm, you can already leave out the pull option in order to only push updates to Supabase without ever fetching any data from Supabase. So you could use the SupabaseClient directly to fetch, and then use rxdb-supabase only to queue changes (possibly while offline) and then push them to Supabase when back online.

This path is currently untested, and because your RxDB is basically empty except for changes, this will always invoke the conflict handler, so you'll have to provide your own for this to work and you don't get the nice conflict resolution. A better way for this to work would be to first add every row you want to update to the RxDB via the pull handler. This wouldn't actually be hard to support via the stream$ interface.

So when you want to do a change in push-only mode, you'd want to:

  1. Call a new method on SupabaseReplication to add the previous state of the document to RxDB
  2. Wait for that sync to finish
  3. Then use the normal RxDB methods for updating
marceljuenemann commented 1 year ago

Note that in this mode you also wouldn't need the _modified and _deleted fields in the database