rememberCoroutineScope

inline fun rememberCoroutineScope(crossinline contextProvider: CoroutineContextProvider = { EmptyCoroutineContext }, supervised: Boolean = false): CoroutineScope

Provides a CoroutineScope that is remembered across recompositions.

Return

A CoroutineScope that is remembered and will be cancelled when the composition leaves.

Parameters

contextProvider

A function that provides the CoroutineContext to be used for the scope.

supervised

Whether to add a SupervisorJob to the coroutine context.


inline fun rememberCoroutineScope(crossinline contextProvider: CoroutineContextProvider = { EmptyCoroutineContext }, crossinline supervisorContextProvider: SupervisorContextProvider = { SupervisorJob() }): CoroutineScope

Provides a CoroutineScope that is remembered across recompositions with a supervisor context provider.

Return

A CoroutineScope that is remembered and will be cancelled when the composition leaves.

Parameters

contextProvider

A function that provides the CoroutineContext to be used for the scope.

supervisorContextProvider

A function that provides the CoroutineContext for a SupervisorJob.