Vivek Modi
07/19/2022, 4:34 PMviewModelScope.launch
so when I call in my compose function, should I use any thing else? I am reading Side-effects using LunchEffect and DispoableEffect. Is this neccessary in my composable function? If yes can someone guide me, bcoz I unable to understand this concept. Thanks
class MainActivityViewModel(private val resultRepository: ResultRepository) : ViewModel() {
init {
getSportResult()
}
fun getSportResult() {
viewModelScope.launch {
val response = resultRepository.getSportResult()
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SetupView(viewModel :MainActivityViewModel = koinViewModel()) {
Scaffold(topBar = {
TopAppBar(
title = { Text(text = stringResource(id = R.string.app_name)) },
)
}, content = { padding ->
Column(
modifier = Modifier
.fillMaxSize()
) {
Button(onClick = { /*TODO*/ }) {
Text(text = stringResource(id = R.string.get_result))
}
}
})
}
Thanks guys..Zach Klippenstein (he/him) [MOD]
07/19/2022, 5:24 PMVivek Modi
07/19/2022, 10:13 PM