Listening in
What fires on document as a page boots, saves, goes dirty and receives live sync.
| Event (on document) | Fires when | detail |
|---|---|---|
clay:ready | clayjs finished booting (same moment clay.ready resolves) | {clay} |
clay:save-saving | a save has been in flight for 500ms (fast saves skip straight to the result) | {msg, timestamp} |
clay:save-saved | the server confirmed the write | {msg, timestamp} |
clay:save-error | the server answered with a problem | {msg, timestamp} |
clay:save-offline | the browser is offline (clayjs re-saves when the connection returns) | {msg, timestamp} |
clay:dirty | the page holds work no save has written. It follows DOM mutations and user input; a script setting a [persist] control's value programmatically is not observed. One event per state change, so a burst of keystrokes is one clay:dirty, and it fires before autosave does | — |
clay:clean | a save (or a verified merge) has accounted for everything the gate saw | — |
clay:snapshot-ready | a snapshot has been cloned, before any stripping. Read detail.documentElement; do not change it. It is also where both change-detection baselines come from, and the change checks do not fire this event, so an edit made here is saved but never compared and the page reads dirty forever. Use clay.addDocumentTransform(fn) to change what gets saved. | {documentElement} |
clay:sync-applied | a live-sync update landed (sync plugin) | {seq, source, by, report, unresolved}; source is peer (another open copy) or disk (the file changed underneath you) |
clay:sorted | a drag-drop reorder landed (sortable plugin); fires on the container and bubbles | {item, from, to, oldIndex, newIndex} |
clay:view-save-attempt | a visitor clicked a [trigger-save] element in view mode; show your own notice | — |