sync Events
Observable SmartWalking lifecycle events.
Emits SmartWalkingEvent subclasses as they happen: SmartWalkingEvent.SyncStarted, SmartWalkingEvent.SyncSubmitted, SmartWalkingEvent.SyncProcessed, SmartWalkingEvent.SyncProcessingTimedOut, SmartWalkingEvent.SyncProcessingDeferred, SmartWalkingEvent.SyncFailed, SmartWalkingEvent.AutoSyncEnabled, and SmartWalkingEvent.AutoSyncDisabled.
SharedFlow semantics (replay = 0) — late subscribers see only events emitted after they attach; there is no stale terminal event re-delivered on subscription (so attaching after a SyncProcessed will not trigger a spurious data refresh). To observe the "is a sync currently running" question, derive state from a collector or call syncSteps directly when you need a fresh sync.
Refresh activity totals on SmartWalkingEvent.SyncProcessed (or SmartWalkingEvent.SyncProcessingTimedOut as a fallback) — that's when the submitted steps are queryable via the Mobile API. SmartWalkingEvent.SyncSubmitted only confirms the SmartWalking API accepted the data, not that it's queryable yet. SmartWalkingEvent.SyncProcessingDeferred means the backend acknowledged the data but did not issue a tracked promotion job — the SDK cannot confirm processing, and data will be picked up on a backend-scheduled cycle (or on the next syncSteps call). Surface a "processing pending" hint if you want users to know.
Kotlin
lifecycleScope.launch {
AFCore.smartWalking().syncEvents.collect { event ->
when (event) {
is SmartWalkingEvent.SyncStarted ->
binding.syncIndicator.isVisible = true
is SmartWalkingEvent.SyncProcessed,
is SmartWalkingEvent.SyncProcessingTimedOut -> {
binding.syncIndicator.isVisible = false
refreshActivities()
}
is SmartWalkingEvent.SyncFailed ->
binding.syncIndicator.isVisible = false
else -> {}
}
}
}