Skip to content

Add koinGet() composable and deprecate koinInject() for naming consistency - #2423

Open
saadkhalidkhan wants to merge 1 commit into
InsertKoinIO:mainfrom
saadkhalidkhan:fix/koin-get-naming-2405
Open

Add koinGet() composable and deprecate koinInject() for naming consistency#2423
saadkhalidkhan wants to merge 1 commit into
InsertKoinIO:mainfrom
saadkhalidkhan:fix/koin-get-naming-2405

Conversation

@saadkhalidkhan

@saadkhalidkhan saadkhalidkhan commented May 25, 2026

Copy link
Copy Markdown

Summary

  • Add koinGet() composable functions as the correctly-named alternative to koinInject()
  • Deprecate koinInject() with @Deprecated + ReplaceWith for easy IDE migration
  • Update Compose docs to use koinGet()

Rationale

In Koin core:

  • KoinComponent.get() / Scope.get() = eager resolution, returns T
  • KoinComponent.inject() / Scope.inject() = lazy resolution, returns Lazy<T>

In Compose, koinInject() calls Scope.get() (eager) but the name suggests lazy resolution.
koinGet() aligns the Compose API naming with core Koin conventions.

Fixes #2405

Test plan

  • koinGet() functions mirror all three overloads of koinInject()
  • Deprecated koinInject() delegates to koinGet() (no behavior change)
  • Built :compose:koin-compose:compileDebugKotlinAndroid successfully
  • Updated compose docs to reference koinGet()

…tency

koinInject() uses Scope.get() (eager resolution) under the hood, but the name implies lazy resolution like Scope.inject(). This adds koinGet() as the correctly-named alternative and deprecates koinInject() with a ReplaceWith migration.

Fixes InsertKoinIOgh-2405
@saadkhalidkhan
saadkhalidkhan force-pushed the fix/koin-get-naming-2405 branch from 262b8b9 to e284f2f Compare May 25, 2026 07:15
@xephosbot

xephosbot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@saadkhalidkhan what do you think about adding an overload for koinInject() that returns Lazy<T>? This would make it more consistent with get() and inject()

@Nailik

Nailik commented Aug 4, 2026

Copy link
Copy Markdown

will koinGet also support @Provided? Currently that is an issue in typesafety check KOIN-D002 is thrown if a different modul provides the implementation and the modul that calls koinInject only knows the interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

org.koin.compose.koinInject has inconsistent naming with Scope functions

3 participants