//MetaPhrase/com.github.diegoberaldin.metaphrase.core.common.architecture/DefaultMviModel
DefaultMviModel
class DefaultMviModel<Intent, State, Effect>(initialState: State) : MviModel<Intent, State, Effect>
Basic implementation of the MVI model. This is useful to easily implement the interface by delegation, minimizing the amount of code that is needed when integrating the MVI pattern. The updateState and emitEffect methods are shortcuts to easily update the UI state and emit a side effect.
Parameters
jvm
Intent | class of intents |
State | class of UI state |
Effect | class of effects |
initialState | initial UI state |
Constructors
DefaultMviModel | [jvm] constructor(initialState: State) Create DefaultMviModel |
Properties
Name | Summary |
---|---|
effects | [jvm] open override val effects: MutableSharedFlow<Effect> One-shot events generated by the state holder. |
uiState | [jvm] open override val uiState: MutableStateFlow<State> Representation of the state holder’s state for the view to consume. |
Functions
Name | Summary |
---|---|
emitEffect | [jvm] suspend fun emitEffect(value: Effect) Emit an effect (event). |
reduce | [jvm] open override fun reduce(intent: Intent) Reduce a view intent updating the uiState accordingly. |
updateState | [jvm] inline fun updateState(block: (State) -> State) Update the UI state. |