Skip to content

Conversation

DominicGBauer
Copy link
Contributor

Description

Add public waitForFirstSync function that will only resolve after the first sync

Work Done

  • Added waitForFirstSync function to PowerSyncDatabaseImpl and PowerSyncDatabase interface
  • Fixed issue in SyncStatus output where a colon should have been an equals sign

Testing

Added waitForFirstSync before and after updateHasSynced function.

  1. If it is placed before then it stops the app as hasSynced is never updated.
  2. If its placed afterwards then the app continues as expected.

@DominicGBauer DominicGBauer self-assigned this Oct 7, 2024
@DominicGBauer DominicGBauer changed the title Feat/add wait for first sync feat: add wait for first sync Oct 7, 2024
@stevensJourney
Copy link
Contributor

Just checking here:
"If it is placed before then it stops the app as hasSynced is never updated."
It might be confusing me since updateHasSynced is an internal function. The testing methodology here might be modifying the SDK behaviour.

In normal conditions, does the hasSynced eventually update to true when the lastSyncedAt updates? This should eventually cause waitForFirstSync to resolve.

@DominicGBauer
Copy link
Contributor Author

Yes waitForFirstSync resolves after hasSynced has been updated.

Copy link
Contributor

@mugikhan mugikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DominicGBauer DominicGBauer merged commit 85da9c6 into main Oct 7, 2024
3 checks passed
@DominicGBauer DominicGBauer deleted the feat/add-wait-for-first-sync branch October 7, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants