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 depends on powersync-ja/powersync-sqlite-core#112 and powersync-ja/powersync-service#313.
This adds support for sync streams to the Dart SDK by implementing the new methods discussed in the "2025-03 Sync streams" design doc. 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
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.