DefaultComponentModel

Constructors

Link copied to clipboard
constructor()
constructor(viewModelScope: CoroutineScope)
constructor(vararg closeables: AutoCloseable)
constructor(viewModelScope: CoroutineScope, vararg closeables: AutoCloseable)

Properties

Link copied to clipboard
abstract val backHandler: BackHandler
Link copied to clipboard
abstract val componentContextFactory: ComponentContextFactory<ComponentContext>
Link copied to clipboard
val ComponentModel.componentScope: CoroutineScope
Link copied to clipboard
abstract val instanceKeeper: InstanceKeeper
Link copied to clipboard
abstract val lifecycle: Lifecycle
Link copied to clipboard
abstract val stateKeeper: StateKeeper

Functions

Link copied to clipboard
override fun addCloseable(closeable: AutoCloseable)

Adds an AutoCloseable resource to this ComponentModel. The resource will be closed right before the onCleared method is called.

override fun addCloseable(key: String, closeable: AutoCloseable)

Adds an AutoCloseable resource with an associated key to this ComponentModel. The resource will be closed right before the onCleared method is called.

Link copied to clipboard
override fun clear()

Clears all resources associated with this ComponentModel and marks it as cleared.

Link copied to clipboard
fun LifecycleOwner.coroutineScope(context: CoroutineContext): CoroutineScope

Extension function to create a CoroutineScope on the current Lifecycle.

Link copied to clipboard
fun LifecycleOwner.defaultScope(): CoroutineScope

Extension function to create a CoroutineScope on the current Lifecycle using the platform defaultDispatcher.

Link copied to clipboard
override fun <T : AutoCloseable> getCloseable(key: String): T?

Returns the AutoCloseable resource associated to the given key, or null if such a key is not present in this ComponentModel.

Link copied to clipboard
fun LifecycleOwner.ioScope(): CoroutineScope

Extension function to create a CoroutineScope on the current Lifecycle using the platform ioDispatcher.

Link copied to clipboard
fun LifecycleOwner.launchDefault(block: suspend CoroutineScope.() -> Unit): Job

Extension function to launch a CoroutineScope on the current Lifecycle using the platform defaultDispatcher.

Link copied to clipboard
fun LifecycleOwner.launchIO(block: suspend CoroutineScope.() -> Unit): Job

Extension function to launch a CoroutineScope on the current Lifecycle using the platform ioDispatcher.

Link copied to clipboard
fun LifecycleOwner.launchMain(block: suspend CoroutineScope.() -> Unit): Job

Extension function to launch a CoroutineScope on the current Lifecycle using the platform mainDispatcher.

Link copied to clipboard
fun LifecycleOwner.mainScope(): CoroutineScope

Extension function to create a CoroutineScope on the current Lifecycle using the platform mainDispatcher.

Link copied to clipboard
open fun onCleared()

This method will be called when this ComponentModel is no longer used and will be destroyed.

Link copied to clipboard
suspend fun LifecycleOwner.repeatOnLifecycle(state: Lifecycle.State = Lifecycle.State.STARTED, block: suspend CoroutineScope.() -> Unit)

LifecycleOwner's extension function for Lifecycle.repeatOnLifecycle to allow an easier call to the API from LifecycleOwners such as Activities and Fragments.