observeAttachmentChanges

Observe attachment changes and upload progress for a specific module and module UID. The subscription remains active while the returned Flow is collected.

Events emitted:

  • AttachmentsUpdated(updatedAttachments, deletedAttachmentUids): DB/realtime-driven content changes.

  • AttachmentUploadStatusChanged(pendingUpload): Upload status/progress for file operations.

Usage example (Kotlin):

val changes = zync.attachments?.observeAttachmentChanges(ZuperModule.JOB, jobUid)
changes?.collect { event ->
when (event) {
is AttachmentChangeEvent.AttachmentsUpdated -> {
val updated = event.updatedAttachments
val deleted = event.deletedAttachmentUids
// handle updated/deleted
}
is AttachmentChangeEvent.AttachmentUploadStatusChanged -> {
val status = event.pendingUpload.status
// handle upload status/progress
}
}
}

Usage example (iOS / Combine):

let cancellable = zync.attachments?.observeAttachmentChangesNative(module: .job, moduleUid: jobUid)
.sink { event in
switch event {
case let .attachmentsUpdated(updatedAttachments: updated, deletedAttachmentUids: deleted):
// handle updated/deleted
case let .attachmentUploadStatusChanged(pendingUpload: upload):
// handle upload status/progress
default: break
}
}

Return

Flow of AttachmentChangeEvent objects

Parameters

module

The module type

moduleUid

The unique identifier of the module instance