useComponentCoroutineScope

fun ComponentScope.useComponentCoroutineScope(coroutineContext: CoroutineContext = EmptyCoroutineContext): CoroutineScope

Return a CoroutineScope that is be active as long as the Component in which it was created is present in the UI tree. The same CoroutineScope instance will be returned across re-renders.

This scope will be cancelled when the Component is removed from the tree or the ComponentTree is released. The optional coroutineContext parameter may not contain a Job as this scope is managed by Litho.

Use this scope to launch coroutines in response to callback events such as clicks or other user interactions where the launched logic may take some time to finish and it's expected that the launched logic should be canceled when the Component is removed from the UI.

You should not use this to launch coroutines directly within Component's render method. For such use cases you should use other hooks such as useCoroutine.

This function will throw if coroutineContext contains a parent Job.