In my app I need to get some values from an API. Currently I'm just doing the API call inside my the init block of a class that I'm injecting using Koin. I'm doing the API call in a runBlocking call from kotlin coroutines but that does block the UI from loading until the variables are set. What would be the proper way of doing this so that it isn't blocking the UI and properly indicates to the user that it's loading?
😶 1
c
Chrimaeon
10/28/2022, 6:16 AM
Please Nicolas, check the channel description for proper other resources where to ask your general android questions.
This is in my viewmodel. It gets called on the main thread which in turn blocks UI. Problem is if I dont block UI then it loads before the actual variables are initialized and then results in errors
g
gildor
10/31/2022, 1:03 AM
You shouldn't rely on initialization order.
Hard to recommend something specific without some self-contained example