-
Notifications
You must be signed in to change notification settings - Fork 30
Sync streams #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sync streams #317
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 tasks
stevensJourney
previously approved these changes
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy with this from my side :D
packages/powersync_core/lib/src/database/powersync_db_mixin.dart
Outdated
Show resolved
Hide resolved
stevensJourney
approved these changes
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for sync streams to the Dart SDK by implementing the new methods discussed in the "2025-03 Sync streams" design doc (public excerpt). Namely:
db.syncStream(name, [params])
returns aSyncStream
instance, which can be used tosubscribe()
to that stream.subscribe()
on aSyncStream
returns aSyncStreamSubscription
, giving you access towaitForFirstSync()
andunsubscribe()
on that subscription.SyncStatus
interface includes a list ofSyncSubscriptionDefinition
s, describing all streams that the client is subscribed to (either due to an explicit subscriptions or because the stream hasauto_subscribe: true
). That interface also reports per-stream download progress.Additional implementation changes support this:
hasSynced
andlastSyncedAt
for individual streams. The core extension gained apowersync_offline_sync_status()
function to help with this, meaning that SDKs no longer have to query the underlying tables directly.SyncStreamSubscription
instance attached to them) can change often and quickly. The TTL feature ensures we don't have to recreate a streaming sync socket every time they change. This is mostly implemented in the sync service, we just send asubscriptions_updated
event and the Rust client tells us whether to restart the iteration or not.ConnectionManager
class to not complicate the mixin even further.I have adopted streams in the
supabase-todolist
demo, with the following sync rules:The idea is that lists are shown by default, and entries in a list are loaded and cached when the page is opened for the first time. This works well, but I really don't like that the API currently requires 50 lines of user code for that. We should probably look into a
powersync_flutter
package with utilities to simplify this eventually.