observe Dashboard Changes
Observe dashboard job changes.
This flow emits events when dashboard jobs are updated during background synchronization, allowing UI to reactively update when job data changes in the cache.
Event Types:
JobsUpdated: Emitted when jobs are inserted, updated, or deleted. Contains the complete list of jobs and updated statistics for immediate UI rendering.
NewUpdatesAvailable: Emitted when sync status changes (e.g., FULL ↔ PARTIAL) but no job data changed. Signals that consumers should refetch to get updated pagination/status info.
Offline-First Behavior:
Only emits during background sync operations, not during initial fetches
Events reflect changes to cached data from server synchronization
Statistics are recalculated from cache for consistency with job data
No filtering by date/module - emits all dashboard changes
Usage Pattern:
zync.jobs.observeDashboardChanges().collect { event ->
when (event) {
is ZyncDashboardUpdatesEvent.JobsUpdated -> {
// Update UI with fresh jobs and stats
updateDashboard(event.jobs, event.stats)
}
is ZyncDashboardUpdatesEvent.NewUpdatesAvailable -> {
// Refetch data to get updated pagination/status
refetchDashboardData()
}
}
}Return
Flow of dashboard update events