-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate to Koin 4.x: Replace deprecated loadKoinModules with upfront declaration #149
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
Conversation
…module declaration Co-authored-by: alex-amenos <11457623+alex-amenos@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR successfully migrates the codebase from Koin's deprecated lazy module loading pattern to Koin 4.x's upfront module declaration approach. The migration eliminates all loadKoinModules() calls and lazy injectXXX() functions, replacing them with a centralized module registration system via BaseApp.getFeatureModules().
Key Changes
- Introduced
getFeatureModules()hook inBaseAppto enable upfront module declaration at application startup - Migrated 10 feature modules from lazy loading to upfront registration in
JetpackApp - Replaced
loadKoinModules()withincludes()for module composition inApiModule
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
shared/core/src/main/java/com/alxnophis/jetpack/core/base/application/BaseApp.kt |
Added getFeatureModules() hook and integrated feature modules into startup initialization |
shared/api/src/main/java/com/alxnophis/jetpack/api/di/ApiModule.kt |
Replaced loadKoinModules() with includes() for sub-module composition |
feature/settings/src/main/java/com/alxnophis/jetpack/settings/di/SettingsModule.kt |
Removed lazy loading wrapper, made module public |
feature/settings/src/main/java/com/alxnophis/jetpack/settings/ui/navigation/SettingsNavGraph.kt |
Removed injectSettings() call from Composable |
feature/posts/src/main/java/com/alxnophis/jetpack/posts/di/PostsModule.kt |
Removed lazy loading wrapper, made module public |
feature/posts/src/main/java/com/alxnophis/jetpack/posts/di/PostDetailModule.kt |
Removed lazy loading wrapper, made module public |
feature/posts/src/main/java/com/alxnophis/jetpack/posts/ui/composable/PostsFeature.kt |
Removed injectPosts() call from Composable |
feature/posts/src/main/java/com/alxnophis/jetpack/posts/ui/composable/PostDetailFeature.kt |
Removed injectPostDetail() call from Composable |
feature/notifications/src/main/java/com/alxnophis/jetpack/notifications/di/NotificationsModule.kt |
Removed lazy loading wrapper, made module public |
feature/notifications/src/main/java/com/alxnophis/jetpack/notifications/ui/navigation/NotificationsNavGraph.kt |
Removed injectNotifications() call from Composable |
feature/my-playground/src/main/java/com/alxnophis/jetpack/myplayground/di/MyPlaygroundModule.kt |
Removed lazy loading wrapper, made module public |
feature/my-playground/src/main/java/com/alxnophis/jetpack/myplayground/ui/composable/MyPlaygroundFeature.kt |
Removed injectMyPlayground() call from Composable |
feature/location-tracker/src/main/java/com/alxnophis/jetpack/location/tracker/di/LocationTrackerModule.kt |
Removed lazy loading wrapper, made module public |
feature/location-tracker/src/main/java/com/alxnophis/jetpack/location/tracker/ui/composable/LocationTrackerFeature.kt |
Removed injectLocationTracker() call from Composable |
feature/home/src/main/java/com/alxnophis/jetpack/home/di/MainModule.kt |
Removed lazy loading wrapper, made module public |
feature/home/src/main/java/com/alxnophis/jetpack/home/ui/composable/HomeFeature.kt |
Removed injectHome() call from Composable |
feature/game/ballclicker/src/main/java/com/alxnophis/jetpack/game/ballclicker/di/BallClickerModule.kt |
Removed lazy loading wrapper, changed from internal to public |
feature/game/ballclicker/src/main/java/com/alxnophis/jetpack/game/ballclicker/ui/composable/BallClickerFeature.kt |
Removed injectBallClicker() call from Composable |
feature/file-downloader/src/main/java/com/alxnophis/jetpack/filedownloader/di/FileDownloaderModule.kt |
Removed lazy loading wrapper, changed from internal to public |
feature/file-downloader/src/main/java/com/alxnophis/jetpack/filedownloader/ui/composable/FileDownloaderFeature.kt |
Removed injectFileDownloader() call from Composable |
feature/authentication/src/main/java/com/alxnophis/jetpack/authentication/di/AuthenticationModule.kt |
Removed lazy loading wrapper, made module public |
feature/authentication/src/main/java/com/alxnophis/jetpack/authentication/ui/composable/AuthenticationFeature.kt |
Removed injectAuthentication() call from Composable |
app/src/main/java/com/alxnophis/jetpack/application/JetpackApp.kt |
Implemented getFeatureModules() to register all 10 feature modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
feature/posts/src/main/java/com/alxnophis/jetpack/posts/di/PostDetailModule.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/alxnophis/jetpack/application/JetpackApp.kt
Outdated
Show resolved
Hide resolved
shared/core/src/main/java/com/alxnophis/jetpack/core/base/application/BaseApp.kt
Outdated
Show resolved
Hide resolved
… and remove unused postDetailModule import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Addresses Koin 4.x breaking changes beyond the
getViewModel→koinViewModelmigration. The codebase used deprecated lazy module loading withloadKoinModules()throughout features, which is no longer supported.Changes
JetpackApp.getFeatureModules()viaBaseApp.getFeatureModules()hookloadKoinModules()calls and lazyinjectXXX()functions across 10 feature modulesloadKoinModules(jsonPlaceholderApiModule)toincludes(jsonPlaceholderApiModule)Before/After
Before (deprecated pattern):
After (Koin 4.x):
Net: -76 lines, improved startup performance, Koin 4.x compliant.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.