Overview
The SaveManager automatically saves project changes to local storage. It watches for timeline and scene changes, debounces save operations, and provides manual control over the save lifecycle.Constructor options
Methods
start()
Starts automatic saving by subscribing to timeline and scene changes.The SaveManager is automatically started when EditorCore is initialized.
stop()
Stops automatic saving and clears all subscriptions.pause()
Temporarily pauses automatic saving without unsubscribing.resume()
Resumes automatic saving after being paused.If there are pending changes when resuming, a save will be queued immediately.
markDirty()
Manually marks the project as having unsaved changes.If true, marks dirty even when paused
Normally you don’t need to call this manually - the SaveManager automatically detects timeline and scene changes.
flush()
Immediately saves all pending changes without waiting for the debounce timer.getIsDirty()
Checks if there are unsaved changes or if a save is in progress.boolean- True if there are pending changes or a save is in progress
How it works
Debouncing
The SaveManager uses a debounce mechanism (default 800ms) to batch multiple changes into a single save operation. When changes are detected:- The save timer is reset
- After 800ms of no changes, the project is saved
- If new changes occur during the timer, it resets again
Automatic detection
The SaveManager automatically subscribes to:- Timeline changes (via
editor.timeline.subscribe()) - Scene changes (via
editor.scenes.subscribe())
Save conditions
A save operation will not run if:- No active project exists
- The SaveManager is paused (unless
force: true) - A save is already in progress
- A project is currently loading
- A project migration is in progress
Best practices
Pause during bulk operations
Pause during bulk operations
Flush before navigation
Flush before navigation
Check dirty state before closing
Check dirty state before closing
See also
- EditorCore - The singleton editor instance
- ProjectManager - Project lifecycle and saving
- Project management feature - User guide