Coroutine scope

With the release of version 0.26.0 of coroutines, a new, important feature was introduced—coroutine scope. All of the coroutine builders from the coroutines-core library are extension functions of the CoroutineScope interface.

The CoroutineScope interface looks as follows:

public interface CoroutineScope {       @Deprecated(level = DeprecationLevel.HIDDEN, message = "Deprecated in favor of top-level extension property")    public val isActive: Boolean        get() = coroutineContext[Job]?.isActive ?: true    public val coroutineContext: CoroutineContext}

We need the coroutine scope to provide a proper cancellation mechanism for the coroutines that we launch in our application. Modern frameworks, such as Android SDK or React Native, are built ...

Get Learn Spring for Android Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.