Skip to content

Commit

Permalink
Merge pull request #1981 from InsertKoinIO/revert_koin_application_co…
Browse files Browse the repository at this point in the history
…mpose

Revert KoinApplication to be more compose natural style
  • Loading branch information
arnaudgiuliani authored Sep 16, 2024
2 parents 54b6ed3 + 0ec790e commit b2f847a
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import org.koin.core.KoinApplication
import org.koin.core.annotation.KoinInternalApi
import org.koin.core.error.KoinApplicationAlreadyStartedException
import org.koin.core.scope.Scope
import org.koin.dsl.KoinAppDeclaration
import org.koin.dsl.koinApplication
import org.koin.mp.KoinPlatform
import org.koin.mp.KoinPlatformTools

Expand Down Expand Up @@ -97,20 +99,19 @@ private fun warningNoContext(ctx: Koin) {
* Start a new Koin Application and associate it for Compose context
* if Koin's Default Context is already set,
*
* @param application - Koin Application declaration lambda (like startKoin)
* @param application - Koin Application declaration lambda
* @param content - following compose function
*
* @throws KoinApplicationAlreadyStartedException
* @throws ApplicationAlreadyStartedException
* @author Arnaud Giuliani
*/
@OptIn(KoinInternalApi::class)
@Composable
@Throws(KoinApplicationAlreadyStartedException::class)
fun KoinApplication(
application: () -> KoinApplication,
application: KoinAppDeclaration,
content: @Composable () -> Unit
) {
val koin = rememberKoinApplication(koinApplication = application())
val koin = rememberKoinApplication(koinApplication = koinApplication(application))
CompositionLocalProvider(
LocalKoinApplication provides koin,
LocalKoinScope provides koin.scopeRegistry.rootScope,
Expand Down

0 comments on commit b2f847a

Please sign in to comment.