From 7924418398e115a849ca9c93ccc65f8be68700dd Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Sun, 22 Jun 2025 05:01:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`feature?= =?UTF-8?q?/#2-base=5Fview=5Fmodel`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @l5x5l. * https://github.com/YAPP-Github/Bitnagil-Android/pull/6#issuecomment-2993938480 The following files were modified: * `presentation/src/main/java/com/threegap/bitnagil/presentation/common/mviviewmodel/MviViewModel.kt` --- .../common/mviviewmodel/MviViewModel.kt | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/common/mviviewmodel/MviViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/common/mviviewmodel/MviViewModel.kt index 1e4ad630..8a03a1c8 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/common/mviviewmodel/MviViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/common/mviviewmodel/MviViewModel.kt @@ -20,14 +20,35 @@ abstract class MviViewModel get() = container.stateFlow val sideEffectFlow: Flow get() = container.sideEffectFlow - protected suspend fun SimpleSyntax.sendSideEffect(sideEffect: SIDE_EFFECT) = postSideEffect(sideEffect) + /** + * Emits a side effect within the Orbit MVI syntax context. + * + * @param sideEffect The side effect to be posted. + */ +protected suspend fun SimpleSyntax.sendSideEffect(sideEffect: SIDE_EFFECT) = postSideEffect(sideEffect) + /** + * Computes a new state in response to the given intent and current state. + * + * Subclasses must implement this to define how each intent transforms the state. + * + * @param intent The intent representing a user or system action. + * @param state The current UI state. + * @return The new state if a state change should occur, or null to leave the state unchanged. + */ protected abstract suspend fun SimpleSyntax.reduceState( intent: INTENT, state: STATE, ): STATE? - fun sendIntent(intent: INTENT) = + /** + * Processes the given intent by invoking state reduction and updating the state if a new state is produced. + * + * If the `reduceState` function returns a non-null state, the container's state is updated accordingly. + * + * @param intent The intent to be handled. + */ + fun sendIntent(intent: INTENT) = intent { val newState = reduceState(intent, state)