Add internal WatchManager class#80
Open
LucDeCaf wants to merge 2 commits into
Open
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
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.
Adds a
WatchManagerclass that manages watched queries, replacing the in-class implementation in PowerSyncDatabase. The old code for watches was difficult to reason about and contained a lot of monkey-patching to support async iterators and schema resets triggering interruptions. This new approach moves all the logic into a dedicatedWatchManagerclass which manages the watch subscription lifecycle and is designed from the ground up with async iterator support and schema resets in mind.Main differences
PowerSyncDatabase.Watch/PowerSyncDatabase.OnChangeare now wrappers aroundWatchManagermethods.SchemaChangedevent is no longer emitted on DB initialization (subject to change).WatchManagermaintains oneTablesUpdatedevent listener which is shared across multiple watches.Also fixes a bug in the Watch_SchemaReset test where DB initialisation was not awaited, causing the test to frequently time out on the
windows-11-armrunner.AI Usage
I blocked out the WatchManager and WatchSubscription classes and wired them up to PowerSyncDatabase and implemented the plumbing methods for WatchManager (Stream, RequestRefresh, CreateSubscription, etc.). I then asked Fable 5 to implement the watch logic using the old code as a reference and edited the results manually to fix some small errors and styling mistakes.