Skip to content

Commit 756a119

Browse files
committed
[WEB] Get apps data from shared viewModel
1 parent baae7c3 commit 756a119

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

web/src/main/kotlin/Application.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import kotlinx.coroutines.GlobalScope
2+
import kotlinx.coroutines.flow.collect
3+
import kotlinx.coroutines.launch
4+
import me.moallemi.kmpshowcase.shared.presentation.AppListViewModel
5+
import org.koin.core.KoinComponent
6+
import org.koin.core.inject
7+
8+
class Application : KoinComponent {
9+
10+
private val appListViewModel: AppListViewModel by inject()
11+
12+
fun load(result: (String) -> Unit) {
13+
GlobalScope.launch {
14+
appListViewModel.apps.collect {
15+
result(it.toString())
16+
}
17+
}
18+
appListViewModel.load()
19+
}
20+
21+
}

web/src/main/kotlin/main.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import kotlinx.browser.document
2+
import me.moallemi.kmpshowcase.shared.di.initKoinJs
23

34
fun main() {
4-
document.body?.textContent = "Welcome"
5+
initKoinJs()
6+
7+
val app = Application()
8+
app.load {
9+
document.body?.textContent = it
10+
}
511
}

0 commit comments

Comments
 (0)