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

DI: Move Koin Android context initialization to MainActivity #507

Merged

Conversation

ksharma-xyz
Copy link
Owner

@ksharma-xyz ksharma-xyz commented Jan 4, 2025

TL;DR

Improved Koin dependency injection setup by removing static Application instance and configuring Android context directly in MainActivity.

What changed?

  • Removed static Application instance from KrailApplication
  • Moved Android context configuration to MainActivity
  • Updated KrailApp composable to accept optional Koin declarations
  • Simplified native configuration in AppModule.android.kt

Why make this change?

Using a static Application instance is an anti-pattern that can lead to memory leaks and makes testing more difficult. This change follows better Android practices by configuring the dependency injection context directly in MainActivity, making the code more maintainable and testable.

Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ksharma-xyz ksharma-xyz changed the title Provide android context to Koin slightly differently DI: Move Koin Android context initialization to MainActivity Jan 4, 2025
@ksharma-xyz ksharma-xyz marked this pull request as ready for review January 4, 2025 22:45
Copy link
Owner Author

ksharma-xyz commented Jan 4, 2025

Merge activity

  • Jan 4, 5:46 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Jan 4, 5:54 PM EST: A user merged this pull request with Graphite.

@ksharma-xyz ksharma-xyz added this to the 1.0.5 milestone Jan 4, 2025
@ksharma-xyz ksharma-xyz merged commit 14df1e3 into main Jan 4, 2025
4 checks passed
@ksharma-xyz ksharma-xyz deleted the 01-05-provide_android_context_to_koin_slightly_differently branch January 4, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant