powersync.dart icon indicating copy to clipboard operation
powersync.dart copied to clipboard

[Demo] Local-only supabase todo app

Open Chriztiaan opened this issue 1 year ago • 6 comments

This adds a demo project that aims to demonstrate how an app could be built starting from a local-only state and later being "upgraded" to a version that has sync capabilities. It started off as a copy of the existing todo app that was stripped of some of the features. The biggest changes are in powersync.dart, login/signup views, and models/schema.dart (which illustrates how to update the schema to supporting syncing).

The readme has a basic description of how everything works, with a small mermaid diagram to show how the app switches from the local-only mode to sync mode.

Chriztiaan avatar Aug 05 '24 11:08 Chriztiaan

@kobiebotha @stevensJourney I've updated the readme, schema comment about switching, and allowed the app to work without specifying credentials in which case login/sign up is disabled.

Chriztiaan avatar Aug 07 '24 08:08 Chriztiaan

Good work! Much needed for a seamless experience. I'll try to implement for my app (Typescript).

guillempuche avatar Aug 07 '24 13:08 guillempuche

Good work! Much needed for a seamless experience. I'll try to implement for my app (Typescript).

Hey @guillempuche, a JS/TS version is on the one in the coming weeks too.

Chriztiaan avatar Aug 08 '24 07:08 Chriztiaan

There is currently a bug where if the user logs in immediately without creating data, existing data doesn't sync down.

Edit: The issue pertains to the .connect() in powersync.dart resolving too early and watch() breaking when logging in without having any local table entries during the switch from local-only to synced mode.

Chriztiaan avatar Aug 08 '24 11:08 Chriztiaan

@Chriztiaan, for defining locally a user id (fingerprint), it can be done with FingerprintJS https://dev.fingerprint.com/docs/identification-vs-fingerprintjs. I'm not sure if this can help you on the Typescript example.

guillempuche avatar Aug 13 '24 10:08 guillempuche

@Chriztiaan, for defining locally a user id (fingerprint), it can be done with FingerprintJS https://dev.fingerprint.com/docs/identification-vs-fingerprintjs. I'm not sure if this can help you on the Typescript example.

This is cool! However I think we want to keep the demos as barebones/unopinionated as possible. I don't currently see a need to demonstrate anything more than a zeroed UUID.

Edit: I think we'll add it somewhere in the documentation though, thanks for the find!

Chriztiaan avatar Aug 13 '24 13:08 Chriztiaan

Using new version sqlite_async that has refreshSchema. Updated powersync package to allow invocation of refreshSchema. Added a test, and using refreshSchema after the schema has been updated in the app.

Chriztiaan avatar Aug 21 '24 08:08 Chriztiaan

I'm ready for Typescript! This is a great feature for a consumer app. Fewer clicks for experiencing the AHA moment, login is a big barrier

guillempuche avatar Sep 09 '24 11:09 guillempuche