Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert KoinApplication to be more compose natural style #1981

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading