From ff822d85dd3abc194c832c06febf0dce88df7cb6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 16 Dec 2022 21:53:49 +0600 Subject: [PATCH] initNavigation with root chain --- CHANGELOG.md | 3 +++ core/src/jsMain/kotlin/InitNavigation.kt | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9710661e..3a7b7649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/core/src/jsMain/kotlin/InitNavigation.kt b/core/src/jsMain/kotlin/InitNavigation.kt index 10cd00bf..48030f74 100644 --- a/core/src/jsMain/kotlin/InitNavigation.kt +++ b/core/src/jsMain/kotlin/InitNavigation.kt @@ -23,9 +23,9 @@ inline fun initNa ), scope: CoroutineScope = CoroutineScope(Dispatchers.Main), savingDebounce: Long = 0L, + rootChain: NavigationChain, nodesFactory: NavigationNodeFactory ): Job { - val rootChain = NavigationChain(null, nodesFactory) val subscope = scope.LinkedSupervisorScope() return subscope.launch { @@ -49,3 +49,22 @@ inline fun initNa ) ?.start(subscope) } } + +@OptIn(InternalSerializationApi::class) +inline fun initNavigation( + startChain: ConfigHolder.Chain, + configsRepo: NavigationConfigsRepo = CookiesNavigationConfigsRepo( + Json { ignoreUnknownKeys = true }, + ConfigHolder.serializer(Base::class.serializer()) + ), + scope: CoroutineScope = CoroutineScope(Dispatchers.Main), + savingDebounce: Long = 0L, + nodesFactory: NavigationNodeFactory +): Job = initNavigation( + startChain, + configsRepo, + scope, + savingDebounce, + NavigationChain(null, nodesFactory), + nodesFactory +)