Skip to content

Commit

Permalink
initNavigation with root chain
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Dec 16, 2022
1 parent eaaf7f6 commit ff822d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 0.0.9

* `JS`:
* `initNavigation` got variant with opportunity to pass root chain

## 0.0.8

* Extended support of JS platform:
Expand Down
21 changes: 20 additions & 1 deletion core/src/jsMain/kotlin/InitNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ inline fun <reified T : Base, reified Base : NavigationNodeDefaultConfig> initNa
),
scope: CoroutineScope = CoroutineScope(Dispatchers.Main),
savingDebounce: Long = 0L,
rootChain: NavigationChain<Base>,
nodesFactory: NavigationNodeFactory<Base>
): Job {
val rootChain = NavigationChain<Base>(null, nodesFactory)
val subscope = scope.LinkedSupervisorScope()

return subscope.launch {
Expand All @@ -49,3 +49,22 @@ inline fun <reified T : Base, reified Base : NavigationNodeDefaultConfig> initNa
) ?.start(subscope)
}
}

@OptIn(InternalSerializationApi::class)
inline fun <reified T : Base, reified Base : NavigationNodeDefaultConfig> initNavigation(
startChain: ConfigHolder.Chain<Base>,
configsRepo: NavigationConfigsRepo<Base> = CookiesNavigationConfigsRepo(
Json { ignoreUnknownKeys = true },
ConfigHolder.serializer(Base::class.serializer())
),
scope: CoroutineScope = CoroutineScope(Dispatchers.Main),
savingDebounce: Long = 0L,
nodesFactory: NavigationNodeFactory<Base>
): Job = initNavigation(
startChain,
configsRepo,
scope,
savingDebounce,
NavigationChain<Base>(null, nodesFactory),
nodesFactory
)

0 comments on commit ff822d8

Please sign in to comment.