AttachedMonitor

@ObjCName(swiftName = "AttachedMonitor")
class AttachedMonitor

Handle to a live monitor subscription.

Returned by BackgroundTaskManager.attachMonitor(...). Call detach to stop delivering events to the monitor without cancelling the surrounding kotlinx.coroutines.CoroutineScope; or let the surrounding scope cancel naturally (e.g. ViewModel teardown) and the subscription tears down with it. detach is idempotent — repeat calls are no-ops.

isActive mirrors the underlying collector coroutine's job — false means the subscription has been detached or the parent scope was cancelled.

Properties

Link copied to clipboard
@ObjCName(swiftName = "isActive")
val isActive: Boolean

true while the monitor is still receiving events.

Functions

Link copied to clipboard
@ObjCName(swiftName = "detach")
fun detach()

Stop delivering events to this monitor. Idempotent — second and later calls are no-ops. Does not affect other monitors attached to the same BackgroundTaskManager.