Draft Auto-Save Handler
Component Detail
Infrastructure
low complexity
mobile
1
Dependencies
2
Dependents
1
Entities
0
Integrations
Description
Riverpod-managed draft state controller that persists note content to Drift on every keystroke with a 500ms debounce, ensuring auto-save is transparent to the user and survives interruptions such as phone calls or push notifications. Prevents data loss on mobile networks common in rural areas where home visits occur.
draft-auto-save-handler
Sources & reasoning
Auto-save with debouncing is a first-class requirement called out in implementation notes due to mobile network unreliability and the risk of mid-sentence interruption. Isolating this logic prevents the editor screen and Note Service from accumulating debounce-timer state.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Debounce keystroke events at 500ms before triggering a Drift write
- Maintain in-memory draft state separate from the persisted note
- Expose save-in-progress and last-saved-at signals to the editor screen
- Clear draft state on successful explicit save or discard
Interfaces
onContentChanged(content: String)
flush(): Future<void>
discardDraft(noteId: String): Future<void>
watchDraftState(noteId: String): Stream<DraftState>