observeNoteChanges

fun observeNoteChanges(module: ZuperModule, moduleUid: String): Flow<NoteChangeEvent>

Observes notes for a specific module with real-time updates and efficient change detection.

This method provides a reactive stream of note changes including:

  • Notes: Real-time updates to note content, metadata, and associations

  • Note Attachments: Changes to attachments linked to notes

  • Attachment Metadata: Updates to attachment details, names, and descriptions

  • Attachment Tags: Changes to tags applied to note attachments

Performance Features:

  • Efficient Change Detection: Only emits when actual changes occur, filtering out duplicate database events

  • Optimized JOINs: Uses comprehensive SQL queries to capture all related data in single database operations

  • Memory Efficient: Processes changes incrementally without loading unnecessary data

Usage Pattern:

zync.notes.observeNoteChanges(ZuperModule.JOB, jobUid).collect { event ->
when (event) {
is NoteChangeEvent.NotesUpdated -> {
// Handle updated notes: event.updatedNotes
// Handle deleted notes: event.deletedNoteUids
}
}
}

Return

Flow of NoteChangeEvent.NotesUpdated containing actual changes to notes and related data

Parameters

module

Module type to observe notes for (e.g., ZuperModule.JOB)

moduleUid

Unique identifier of the module instance