EquinoxViewModel

abstract class EquinoxViewModel(val snackbarHostState: SnackbarHostState? = null) : ViewModel, Retriever.RetrieverWrapper

The EquinoxViewModel class is the support class used by the related activities to communicate with the backend and to execute the refreshing routines to update the UI data

Related documentation: EquinoxViewModel

Author

N7ghtm4r3 - Tecknobit

Parameters

snackbarHostState

The host to launch the snackbar messages

See also

Inheritors

Constructors

Link copied to clipboard
constructor(snackbarHostState: SnackbarHostState? = null)

Properties

Link copied to clipboard
private val retriever: Retriever

retriever the manager used to fetch the data from the backend

Link copied to clipboard

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
open override fun canRetrieverStart(): Boolean

Method used to get whether the viewModelScope can start, so if there aren't other jobs that routine is already executing

Link copied to clipboard
open override fun continueToRetrieve(currentContext: KClass<*>): Boolean

Method used to suspend the current viewModelScope to execute other requests to the backend, the isRefreshing instance will be set as false to allow the restart of the routine after executing the other requests

Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
protected expect open fun onCleared()
Link copied to clipboard
open override fun restartRetriever()

Method used to restart the current viewModelScope after other requests has been executed, the isRefreshing instance will be set as true to deny the restart of the routine after executing the other requests

Link copied to clipboard
open fun restartRetrieverIf(condition: Boolean)

Method used to conditionally restart the current retrieverScope after other requests has been executed, the isRefreshing instance will be set as true to deny the restart of the routine after executing the other requests

Link copied to clipboard
open override fun retrieve(currentContext: KClass<*>, routine: suspend () -> Unit, repeatRoutine: Boolean, refreshDelay: Long)

Method used to execute the refresh routine designed

Link copied to clipboard
open fun setActiveContext(currentContext: KClass<*>)

Method used to set the current active context where the retrieverScope is executing

Link copied to clipboard
fun showSnackbarMessage(    message: String,     actionLabel: String? = null,     onDismiss: () -> Unit? = null,     onActionPerformed: () -> Unit? = null,     withDismissAction: Boolean = false,     duration: SnackbarDuration = if (actionLabel == null) SnackbarDuration.Short else SnackbarDuration.Indefinite)
fun showSnackbarMessage(    response: JsonObject,     actionLabel: String? = null,     onDismiss: () -> Unit? = null,     onActionPerformed: () -> Unit? = null,     withDismissAction: Boolean = false,     duration: SnackbarDuration = if (actionLabel == null) SnackbarDuration.Short else SnackbarDuration.Indefinite)
fun showSnackbarMessage(    message: StringResource,     actionLabel: StringResource? = null,     onDismiss: () -> Unit? = null,     onActionPerformed: () -> Unit? = null,     withDismissAction: Boolean = false,     duration: SnackbarDuration = if (actionLabel == null) SnackbarDuration.Short else SnackbarDuration.Indefinite)

Method used to display a response message with a snackbar

Link copied to clipboard
open override fun suspendRetriever()

Method used to suspend the current viewModelScope to execute other requests to the backend, the isRefreshing instance will be set as false to allow the restart of the routine after executing the other requests

Link copied to clipboard
open fun suspendRetrieverIf(condition: Boolean)

Method used to conditionally suspend the current retrieverScope to execute other requests to the backend, the isRefreshing instance will be set as false to allow the restart of the routine after executing the other requests