Michał Konkel
01/02/2024, 11:09 AMApp() {
LaunchedEffect(Unit) {
fetchUsers()
}
}
fetchUsers() is a suspend function that feteches users fro the backend.
On Android and iOS the function is invoked and users are listed in the console.
On WASM there is infinite loop that after every fetchUsers()
invocation reloades the whole pageOleksandr Karpovich [JB]
01/02/2024, 11:10 AMMichał Konkel
01/02/2024, 11:14 AM1.8.0-RC
Michał Konkel
01/02/2024, 11:14 AMMichał Konkel
01/02/2024, 11:21 AM1.8.0-rc
Michał Konkel
01/02/2024, 11:27 AMMichał Konkel
01/02/2024, 11:29 AMfetchUsers
is provided via presentation
presentation is provided via simple service locator
objec DI {
val presentationFactory by lazy {
RealPresentationFactory()
}
}
so the whole code looks like that:
App() {
val presentation = remember { DI.presentationFactory.createAppPresentation() }
LaunchedEffect(Unit) {
presentation.getUsers()
}
}
Oleksandr Karpovich [JB]
01/02/2024, 11:32 AMfun main() {
MainScope().launch {
fetchUsers()
println("Done")
}
}
_Michał Konkel
01/02/2024, 11:55 AMLaunchedEffect(Unit) {
test()
}
private suspend fun test() {
(1..10).forEach {
deleay(5000)
printLn(it)
}
}
and it's working okOleksandr Karpovich [JB]
01/02/2024, 11:55 AMMichał Konkel
01/02/2024, 11:56 AMMichał Konkel
01/02/2024, 11:56 AMOleksandr Karpovich [JB]
01/02/2024, 11:57 AMMichał Konkel
01/02/2024, 12:42 PMMichał Konkel
01/02/2024, 12:45 PMLaunchedEffect() {
presentaton.fetchUsers()
}
...
suspend fun fetchUsers() {
delay(5000)
return listOf(User, User)
}
Works OK
LaunchedEffect() {
<http://client.post|client.post>("/login") ...
}
...
client = HttpClient { ... }
LoopMichał Konkel
01/06/2024, 7:30 AM