Created
August 10, 2020 12:53
-
-
Save szugyi/5f0afd94399950382ebf19acf0f8afcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CounterAnalyticsModel @Inject constructor( | |
private val analyticsTracker: AnalyticsTracker | |
) : AnalyticsModel<CounterViewModel>() { | |
override fun onScreenViewModelAttached() { | |
viewModel.viewModelScope.launch { | |
flowOf( | |
viewModel.decrementValue | |
.getExecutedEvents() | |
.onEach { | |
analyticsTracker.logEvent( | |
Event.DECREMENT_CLICKED, | |
Param.VALUE to viewModel.value.value!! | |
) | |
}, | |
viewModel.incrementValue | |
.getExecutedEvents() | |
.onEach { | |
analyticsTracker.logEvent( | |
Event.INCREMENT_CLICKED, | |
Param.VALUE to viewModel.value.value!! | |
) | |
} | |
).flattenMerge() | |
.collect() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment