jazz icon indicating copy to clipboard operation
jazz copied to clipboard

feat: introduce priority handling for CoValue updates and implement batching for low priority subscriptions

Open gdorsi opened this issue 1 month ago • 1 comments

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

gdorsi avatar Nov 07 '25 18:11 gdorsi

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
design-system Ready Ready Preview Comment Nov 7, 2025 6:50pm
file-upload-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
form-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
gcmp-homepage Ready Ready Preview Comment Nov 7, 2025 6:50pm
image-upload-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-chat Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-chat-1 Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-chat-2 Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-filestream Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-image-upload Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-inspector Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-multi-cursors Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-organization Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-paper-scissors Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-richtext Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-richtext-prosekit Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-richtext-tiptap Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-todo Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-vector-search Ready Ready Preview Comment Nov 7, 2025 6:50pm
jazz-version-history Ready Ready Preview Comment Nov 7, 2025 6:50pm
music-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
passkey-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
passphrase-auth-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
quint-ui Ready Ready Preview Comment Nov 7, 2025 6:50pm
reactions-demo Ready Ready Preview Comment Nov 7, 2025 6:50pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
jazz-homepage Ignored Ignored Preview Nov 7, 2025 6:50pm

vercel[bot] avatar Nov 07 '25 18:11 vercel[bot]