https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
u

ursus

03/16/2021, 2:42 AM
Copy code
class ViewModel {
	
	fun sync() {
		setState { copy(syncInFlightCounter = syncInFlightCounter + 1 )}
		...
		setState { copy(syncInFlightCounter = syncInFlightCounter - 1 )}
	}

	data class State(val syncInFlightCounter = 0)
}

...

viewModel.state
	.subscribe { state ->
		progressBar.show = state.syncInFlightCounter  > 0
	}