Skip to content

Commit

Permalink
[#3933] Move loadings into beginning of observations (#3934)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan authored Sep 15, 2024
1 parent e19dbf3 commit 03d1aa0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CalculatorViewModel(
private fun observeBase() = state.map { it.base }
.distinctUntilChanged()
.onEach {
setState { copy(loading = true) }
Logger.d { "CalculatorViewModel observeBase $it" }
calculationStorage.currentBase = it
currentBaseChanged(it)
Expand All @@ -91,15 +92,14 @@ class CalculatorViewModel(
private fun observeInput() = state.map { it.input }
.distinctUntilChanged()
.onEach {
setState { copy(loading = true) }
Logger.d { "CalculatorViewModel observeInput $it" }
calculationStorage.lastInput = it
calculateOutput(it)
}
.launchIn(viewModelScope)

private fun updateConversion() {
setState { copy(loading = true) }

data.conversion?.let {
calculateConversions(it, ConversionState.Cached(it.date))
} ?: viewModelScope.launch {
Expand Down

0 comments on commit 03d1aa0

Please sign in to comment.