-
Notifications
You must be signed in to change notification settings - Fork 3
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
Question on init mutations #38
Comments
Good question. It's because for this application each new page load is a different (anonymous) "user" and so it's right to create a new client state for each page load. We don't need to wait for initial sync to see if there's any data there. The shapes on the other hand should only be created once for the entire room. |
PS: Fine to ask questions here, but also discord is available. You can ask reflect questions there too: https://discord.replicache.dev. |
I'm entirely confused about how the above code achieves this : ) The docs say
So I would expect that callback to be called on the first sync, regardless of whether this is a new room or a reload of an existing one. The only reason it's not called over and over, as I understand, is the callback de-registers itself (53). Every time the page loads it's going to assign that callback to r.onSync, so it's going to be called once. I mean, I can see it behaves as you say, but I have no idea why! Maybe my mental model of what a "sync" is, is wrong. I understand that to mean any time mutations from some other client are applied to the state of this client. Related question: how is a room created anyway? Is it this? |
The
If it finds the Actually now that I think of it this code dates to a version of Replidraw where persistence was turned off for performance, so I think we could now run this mutator before sync and it would work the same way. Because we now store the synced data locally so we can detect whether we've already initialized without waiting for first sync. |
Yes, this is right. The client-side API for reflect is still a bit wonky - we will soon merge |
https://github.com/rocicorp/replidraw-do/blob/d4f191ea47a885636214db1451feccac807d25d2/src/pages/d/%5Bid%5D.tsx#L47-L56
Why is it OK here to call
initClientState
directly, whileinitShapes
is delayed until after the first sync?(Also, LMK if this is/isn't a good place to ask questions)
The text was updated successfully, but these errors were encountered: