jazz
jazz copied to clipboard
feat: introduce priority handling for CoValue updates and implement batching for low priority subscriptions
Description
This PR introduces a batching system for CoValue updates.
Any subscribe done from CoValue schema is now deferred and batched:
Person.subscribe(
person.$jazz.id,
{ resolve: { dogs: : { $each: true } } },
update,
)
person.dogs.$jazz.set("giggino", { name: "Giggino" });
person.dogs.$jazz.set("leila", { name: "Leila" });
person.dogs.leila?.$jazz.set("name", "Leila");
person.dogs.giggino?.$jazz.set("name", "Giggino");
// update is going to be triggered only once
For UI frameworks and calls to subscribeToCoValue with syncResolution: true will only batch updates coming from remote peers and storage:
const value = useCoState(Person, id)
const doStuff = () => {
person.dogs.$jazz.set("giggino", { name: "Giggino" });
// Update triggered here
person.dogs.$jazz.set("leila", { name: "Leila" });
// Update triggered here
}
This is done to ensure that inputs interactions perserve the cursor position in React.
TODO:
- [ ] Fix the broken test on subscribe
- [ ] Test the priority values emitted by CoValueCore
- [ ] Check if in Svelte we can get away with some batching
Tests
- [ ] Tests have been added and/or updated
- [ ] Tests have not been updated, because:
- [ ] I need help with writing tests
Checklist
- [ ] I've updated the part of the docs that are affected the PR changes
- [ ] I've generated a changeset, if a version bump is required
- [ ] I've updated the jsDoc comments to the public APIs I've modified, or added them when missing
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| jazz-homepage | Preview | Nov 7, 2025 6:50pm |