@@ -10,7 +10,6 @@ import app.cash.molecule.RecompositionMode
1010import app.cash.molecule.launchMolecule
1111import com.rickclephas.kmp.observableviewmodel.ViewModel
1212import com.rickclephas.kmp.observableviewmodel.coroutineScope
13- import com.rickclephas.kmp.observableviewmodel.launch
1413import dev.johnoreilly.climatetrace.data.ClimateTraceRepository
1514import dev.johnoreilly.climatetrace.remote.Country
1615import dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo
@@ -42,22 +41,18 @@ sealed interface CountryDetailsEvents {
4241open class CountryDetailsViewModel : ViewModel (), KoinComponent {
4342 private val climateTraceRepository: ClimateTraceRepository by inject()
4443
45- private val events = MutableSharedFlow <CountryDetailsEvents >()
44+ private val events = MutableSharedFlow <CountryDetailsEvents >(extraBufferCapacity = 20 )
4645
4746 val viewState: StateFlow <CountryDetailsUIState > = viewModelScope.coroutineScope.launchMolecule(mode = RecompositionMode .Immediate ) {
4847 CountryDetailsPresenter (events)
4948 }
5049
5150 fun setYear (year : String ) {
52- viewModelScope.launch {
53- events.emit(CountryDetailsEvents .SetYear (year))
54- }
51+ events.tryEmit(CountryDetailsEvents .SetYear (year))
5552 }
5653
5754 fun setCountry (country : Country ) {
58- viewModelScope.launch {
59- events.emit(CountryDetailsEvents .SetCountry (country))
60- }
55+ events.tryEmit(CountryDetailsEvents .SetCountry (country))
6156 }
6257
6358 @Composable
0 commit comments