@@ -10,7 +10,6 @@ import app.cash.molecule.RecompositionMode
10
10
import app.cash.molecule.launchMolecule
11
11
import com.rickclephas.kmp.observableviewmodel.ViewModel
12
12
import com.rickclephas.kmp.observableviewmodel.coroutineScope
13
- import com.rickclephas.kmp.observableviewmodel.launch
14
13
import dev.johnoreilly.climatetrace.data.ClimateTraceRepository
15
14
import dev.johnoreilly.climatetrace.remote.Country
16
15
import dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo
@@ -42,22 +41,18 @@ sealed interface CountryDetailsEvents {
42
41
open class CountryDetailsViewModel : ViewModel (), KoinComponent {
43
42
private val climateTraceRepository: ClimateTraceRepository by inject()
44
43
45
- private val events = MutableSharedFlow <CountryDetailsEvents >()
44
+ private val events = MutableSharedFlow <CountryDetailsEvents >(extraBufferCapacity = 20 )
46
45
47
46
val viewState: StateFlow <CountryDetailsUIState > = viewModelScope.coroutineScope.launchMolecule(mode = RecompositionMode .Immediate ) {
48
47
CountryDetailsPresenter (events)
49
48
}
50
49
51
50
fun setYear (year : String ) {
52
- viewModelScope.launch {
53
- events.emit(CountryDetailsEvents .SetYear (year))
54
- }
51
+ events.tryEmit(CountryDetailsEvents .SetYear (year))
55
52
}
56
53
57
54
fun setCountry (country : Country ) {
58
- viewModelScope.launch {
59
- events.emit(CountryDetailsEvents .SetCountry (country))
60
- }
55
+ events.tryEmit(CountryDetailsEvents .SetCountry (country))
61
56
}
62
57
63
58
@Composable
0 commit comments