Hello, quick sanity check: is this reasonable? ```...
# compose
d
Hello, quick sanity check: is this reasonable?
Copy code
LaunchedEffect(Unit) {
    withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
        while (true) {
            val (_, response) = Fuel.get("<http://127.0.0.1:8080/test.img>").response()
            img = loadImageBitmap(response.body().toStream())
            delay(RELOAD_DURATION)
        }
    }
}
Or are there better ways to run a webrequest in a loop on a delay in a coroutine? img is a
by remember { mutableStateOf(...) }
x
You shouldn't be performing Http request in Composable functions. That's not aligned with the guidelines, so it will be confusing. In addition, you won't be able to test your business logic if you're doing this. You should have some UI state holder (i.e. Presenter or ViewModel) that would perform the Http request. You should wrap the model returned by the request in an
State
or
MutableState
and read that from the Composable function.