LifecycleCoroutineScope
public abstract class LifecycleCoroutineScope implements CoroutineScope
CoroutineScope tied to a Lifecycle and Dispatchers.Main.immediate
This scope will be cancelled when the Lifecycle is destroyed.
Summary
Public methods |
|
|---|---|
final @NonNull Job |
This method is deprecated. launchWhenCreated is deprecated as it can lead to wasted resources in some cases. |
final @NonNull Job |
This method is deprecated. launchWhenResumed is deprecated as it can lead to wasted resources in some cases. |
final @NonNull Job |
This method is deprecated. launchWhenStarted is deprecated as it can lead to wasted resources in some cases. |
Inherited methods |
||||
|---|---|---|---|---|
|
Public methods
launchWhenCreated
public final @NonNull JoblaunchWhenCreated(
@NonNull SuspendFunction1<@NonNull CoroutineScope, Unit> block
)
Launches and runs the given block when the Lifecycle controlling this LifecycleCoroutineScope is at least in Lifecycle.State.CREATED state.
The returned Job will be cancelled when the Lifecycle is destroyed.
| See also | |
|---|---|
whenCreated |
|
coroutineScope |
launchWhenResumed
public final @NonNull JoblaunchWhenResumed(
@NonNull SuspendFunction1<@NonNull CoroutineScope, Unit> block
)
Launches and runs the given block when the Lifecycle controlling this LifecycleCoroutineScope is at least in Lifecycle.State.RESUMED state.
The returned Job will be cancelled when the Lifecycle is destroyed.
| See also | |
|---|---|
whenResumed |
|
coroutineScope |
launchWhenStarted
public final @NonNull JoblaunchWhenStarted(
@NonNull SuspendFunction1<@NonNull CoroutineScope, Unit> block
)
Launches and runs the given block when the Lifecycle controlling this LifecycleCoroutineScope is at least in Lifecycle.State.STARTED state.
The returned Job will be cancelled when the Lifecycle is destroyed.
| See also | |
|---|---|
whenStarted |
|
coroutineScope |