Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 3878d9e

Browse files
committed
Refactor Zipline flow reference
1 parent 376274e commit 3878d9e

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

samples/discovery/zipline/src/androidMain/kotlin/com/dropbox/componentbox/samples/discovery/DiscoveryZipline.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.dropbox.componentbox.samples.discovery
22

33
import app.cash.zipline.Zipline
4-
import app.cash.zipline.asFlowReference
54
import kotlinx.coroutines.CoroutineScope
65
import kotlinx.coroutines.asCoroutineDispatcher
76
import kotlinx.coroutines.flow.Flow
@@ -31,10 +30,7 @@ class DiscoveryZipline {
3130
zipline.bind<HostApi>("hostApi", hostApi)
3231
zipline.quickJs.evaluate(PREPARE_PRESENTERS_SCRIPT)
3332
val presenter = zipline.take<DiscoveryPresenter>("discoveryPresenter")
34-
val eventsFlowReference = eventFlow.asFlowReference()
35-
val modelsFlowReference = presenter.produceModels()
36-
37-
val modelsFlow = modelsFlowReference.take()
33+
val modelsFlow = presenter.produceModels()
3834
modelsStateFlow.emitAll(modelsFlow)
3935
}
4036

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.dropbox.componentbox.samples.discovery
22

3-
import app.cash.zipline.FlowReference
43
import app.cash.zipline.ZiplineService
4+
import kotlinx.coroutines.flow.Flow
55

66
interface DiscoveryPresenter : ZiplineService {
7-
suspend fun produceModels(): FlowReference<DiscoveryScreenViewModel>
7+
suspend fun produceModels(): Flow<DiscoveryScreenViewModel>
88
}

samples/discovery/zipline/src/jsMain/kotlin/com/dropbox/componentbox/samples/discovery/RealDiscoveryPresenter.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.dropbox.componentbox.samples.discovery
22

3-
import app.cash.zipline.FlowReference
4-
import app.cash.zipline.asFlowReference
53
import com.dropbox.componentbox.models.ComponentBox
64
import kotlinx.coroutines.coroutineScope
75
import kotlinx.coroutines.flow.Flow
@@ -14,13 +12,12 @@ class RealDiscoveryPresenter(
1412
) : DiscoveryPresenter {
1513
private lateinit var screen: ComponentBox.Screen
1614

17-
override suspend fun produceModels(): FlowReference<DiscoveryScreenViewModel> {
15+
override suspend fun produceModels(): Flow<DiscoveryScreenViewModel> {
1816
return coroutineScope {
19-
val flow: Flow<DiscoveryScreenViewModel> = channelFlow {
17+
channelFlow {
2018
loadComponentIndex()
2119
send(produceModel())
2220
}
23-
flow.asFlowReference()
2421
}
2522
}
2623

0 commit comments

Comments
 (0)