-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
reliable 'synced' or loaded event #35
Comments
As far as I know, what you are wanting is how https://codesandbox.io/p/sandbox/y-indexeddb-updates-test-forked-6mf9xl Feel free to fork that sandbox to create a reproducible demo of the problem you're experiencing. |
@raineorshine thanks for the quick reply and providing the sandbox link, I will try to replicate it there. For reference the event does fire consistently however for the same document the handler will sometimes show empty content on that event. Is it possible that there is a race condition between that event being fired and the content being available to read in the ydoc object? perhaps I also misinterpreted the README and specifically this wording:
This seems to suggest that content will be available after that event is fired |
The Given this, I interpret the README to mean that the |
After more investigation I can confirm that the issue was elsewhere. I must admit I did jump to conclusions after seeing
thinking that the content would somehow be loaded or available after the event was fired |
Great, I'm glad you got to the bottom of it. I agree the language is ambiguous. If you have the time, please consider opening a PR to change the wording so that others do not experience the same confusion. |
attempt to clarify slight ambiguity around the sync event description fix yjs#35
@raineorshine sorry it took me so long to make this propose this simple change but here it is: #37 |
Hi @ben-bourdin451 what issue were you running into? I am also seeing the 'synced' event fire twice, once before the existing updates are applied and once after. Wondering if this is similar to what you experienced. |
Is your feature request related to a problem? Please describe.
The current synced event has the following description in the readme
Describe the solution you'd like
I would like to be able to have an event that is fired once the content is guaranteed to be available. It could be 'synced' or another event.
Knowing when a ydoc has been 'loaded' is important to state external to this plugin, an example use case is: handling empty docs. From my testing this is not currently possible.
Describe alternatives you've considered
I've considered a few different approaches (timeouts, update event from ydoc) but none seem to work 100%
Additional context
I've tried looking for similar issues or discussions related to this but couldn't find any. Perhaps this is due to an implementation detail that I'm not aware of since I'm not familiar with the inner workings of this plugin. Something similar to the state provided in the WS plugin would be ideal.
Some guidance or clarity on this subject would be greatly appreciated 🙏
The text was updated successfully, but these errors were encountered: