Skip to content

Commit

Permalink
Fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-mikhailovskii-idf committed Jan 19, 2025
1 parent 31f5b53 commit 8325895
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.koin.decompose

import com.arkivanov.essenty.lifecycle.doOnDestroy
import org.koin.core.annotation.KoinExperimentalAPI
import org.koin.core.component.getScopeId
import org.koin.core.component.getScopeName
import org.koin.core.scope.Scope
Expand All @@ -10,14 +11,17 @@ import org.koin.core.scope.ScopeCallback
* Create Scope for Component.
* Doesn't link to parent component's Scope
*/
@KoinExperimentalAPI
fun DecomposeScopeComponent.createComponentScope() =
getKoin().getScopeOrNull(getScopeId()) ?: createScopeForCurrentLifecycle()

/**
* Provide scope tied to Component
*/
@KoinExperimentalAPI
fun DecomposeScopeComponent.componentScope() = lazy { createComponentScope() }

@OptIn(KoinExperimentalAPI::class)
private fun DecomposeScopeComponent.createScopeForCurrentLifecycle(): Scope {
val scope = getKoin().createScope(getScopeId(), getScopeName(), this)
scope.registerCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.koin.decompose

import com.arkivanov.decompose.ComponentContext
import org.koin.core.annotation.KoinExperimentalAPI
import org.koin.core.component.KoinScopeComponent
import org.koin.core.scope.Scope

/**
* Decompose Component that can handle a Koin Scope
*/
@KoinExperimentalAPI
interface DecomposeScopeComponent : KoinScopeComponent, ComponentContext {

/**
Expand Down

0 comments on commit 8325895

Please sign in to comment.