Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support isSynced in Yjs #370

Open
paulgb opened this issue Jan 14, 2025 · 0 comments
Open

Support isSynced in Yjs #370

paulgb opened this issue Jan 14, 2025 · 0 comments

Comments

@paulgb
Copy link
Member

paulgb commented Jan 14, 2025

Y.Doc has a field isSynced which corresponds to YSweetProvider's synced property (equivalent to status === STATUS_CONNECTED).

The field is not mentioned in the Yjs docs, but it's probably worth implementing anyway for compatibility. The yjs source says:

This is set to true when the connection provider has successfully synced with a backend.
Note that when using peer-to-peer providers this event may not provide very useful.
Also note that not all providers implement this feature. Provider authors are encouraged to fire
the sync event when the doc has been synced (with true as a parameter) or if connection is
lost (with false as a parameter).

In the meantime, developers can access .synced on the YSweetProvider instance instead of the Y.Doc, which is equivalent. They can also use .hasLocalChanges, which reflects whether changes after the initial connection handshake are synced, not just that the initial handshake is complete as .isSynced implies.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant