Skip to content

Commit c30e847

Browse files
getEntryProvider function
1 parent 35b26ef commit c30e847

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/java/com/example/nav3recipes/modular/koin/KoinModularActivity.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,19 @@ inline fun ComponentCallbacks.entryProvider(
5555
entryProvider
5656
}
5757

58+
@OptIn(KoinInternalApi::class)
59+
inline fun ComponentCallbacks.getEntryProvider() : EntryProvider {
60+
val entries = getKoinScope().getAll<EntryProviderInstaller>()
61+
val entryProvider: (Any) -> NavEntry<Any> = entryProvider {
62+
entries.forEach { builder -> this.builder() }
63+
}
64+
return entryProvider
65+
}
66+
5867
class KoinModularActivity : ComponentActivity(), AndroidScopeComponent {
5968

6069
override val scope : Scope by activityRetainedScope()
6170
val navigator: Navigator by inject()
62-
val entryProvider : EntryProvider by entryProvider()
6371

6472
override fun onCreate(savedInstanceState: Bundle?) {
6573
super.onCreate(savedInstanceState)
@@ -81,7 +89,7 @@ class KoinModularActivity : ComponentActivity(), AndroidScopeComponent {
8189
backStack = navigator.backStack,
8290
modifier = Modifier.padding(paddingValues),
8391
onBack = { navigator.goBack() },
84-
entryProvider = entryProvider
92+
entryProvider = getEntryProvider()
8593
)
8694
}
8795
}

0 commit comments

Comments
 (0)