Ryan Payne
04/04/2026, 12:50 AMsample-viewmodel package.
Given that androidx.compose.ui.platform.AndroidUiDispatcher.Main only exists in androidMain, what should I use instead?
abstract class MoleculeViewModel<Event, Model> : ViewModel() {
private val scope = CoroutineScope(
viewModelScope.coroutineContext + AndroidUiDispatcher.Main <<<<<< Reference not available in commonMain or iosMain
)
// ...
}
P.S. I'm new to molecule and the sample-viewmodel package has been a helpful starting point. However, I'm open to other approaches.Ryan Payne
04/04/2026, 12:55 AMexpect MoleculeViewModel and then actual MoleculeViewModel for iosMain and androidMain.
However, it would great if there was a dispatcher I could use for both so I can reduce the duplication and just have a single MoleculeViewModel in commonMain.Chrimaeon
04/04/2026, 9:30 AM