From 00fe6edcf1fb7a94f17f426e063ebeab3c4f868f Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 14 Apr 2023 11:40:40 -0500 Subject: [PATCH] Updated protected ViewModel.actions property to be ViewModel.actionEvents --- .../commonMain/kotlin/com.chrynan.cycle/ViewModel.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cycle-core/src/commonMain/kotlin/com.chrynan.cycle/ViewModel.kt b/cycle-core/src/commonMain/kotlin/com.chrynan.cycle/ViewModel.kt index a57cb72..21388b6 100644 --- a/cycle-core/src/commonMain/kotlin/com.chrynan.cycle/ViewModel.kt +++ b/cycle-core/src/commonMain/kotlin/com.chrynan.cycle/ViewModel.kt @@ -69,10 +69,10 @@ abstract class ViewModel( } /** - * A [MutableStateFlow] of [Action]s that represent the [Action]s being performed via calls to the [perform] - * function. + * A [MutableStateFlow] of [Action] [Event]s that represent the [Action]s being performed via calls to the + * [perform] function. */ - protected val actions = MutableStateFlow?>(null) + protected val actionEvents = MutableStateFlow?>?>(null) private lateinit var job: Job @@ -157,7 +157,7 @@ abstract class ViewModel( * producing a new [State]. */ protected open fun perform(action: Action) { - actions.value = action + actionEvents.value = Event(action) } /** @@ -178,7 +178,7 @@ abstract class ViewModel( * Presenter is not already bound. */ protected open fun onBind() { - actions.filterNotNull() + actionEvents.mapNotNull { it?.value } .flatMap(flatMapStrategy) { it.invoke(currentState) } .onEach { stateStore.dispatch(it) } .launchIn(coroutineScope)