Editing patterns
StartupJS is reactive by default: when you update a document, every subscribed client sees the change immediately. That is great for collaboration, but sometimes you want a local draft that only saves on demand.
Setup: create a demo document
Live editing (default behavior)
Changes are written to the document immediately, so the UI stays in sync with the database.
Local draft (save on button click)
If you want a "Save" button, keep a local copy and only write changes to the document when the user confirms.
Persistent draft (survives reloads)
If the draft must survive page reloads, store it in a separate document. A common convention is:
Why assign
Use $doc.assign(draft) instead of replacing the entire document. It sets only the fields that changed, generating minimal operations and avoiding unnecessary re-renders in components that depend on unchanged fields.