activityEvents

Observable stream of server-confirmed calendar changes.

Emits a MemberActivityEvent whenever a SmartWalking sync is processed, a member visit is added or removed, a self-report is added or removed, or a FitAtHome selfie is added or removed — provided the backend actually accepted the change (duplicates and validation failures do not fire).

Use this as a "refresh now" signal. A calendar screen typically:

  1. Calls get on mount to render the current month.

  2. Subscribes to activityEvents and re-fetches the visible month on every emission (or selectively, based on the event subtype).

SharedFlow(replay = 0) semantics: a subscriber that attaches after an event has fired does NOT receive that event on attach — so reopening a screen does not trigger a spurious refresh. Pair attach with a fresh get call to capture the current state.

Offline submissions are deferred: a submit* that returns AFResult.queued does NOT fire an event immediately. The event fires when the outbox flush delivers the submission to the server and the server acknowledges it.

Kotlin

lifecycleScope.launch {
AFCore.activities().activityEvents.collect { event ->
when (event) {
is MemberActivityEvent.StepsAdded,
is MemberActivityEvent.MemberVisitAdded,
is MemberActivityEvent.MemberVisitRemoved,
is MemberActivityEvent.SelfReportAdded,
is MemberActivityEvent.SelfReportRemoved,
is MemberActivityEvent.SelfieAdded,
is MemberActivityEvent.SelfieRemoved -> refreshVisibleMonth()
}
}
}

Swift

See subscribeToActivityEvents for a callback-based bridge that does not require Kotlin Flow interop.