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

ClosedScopeException on Device Rotation with koinInject #1773

Closed
gecko10000 opened this issue Jan 29, 2024 · 5 comments
Closed

ClosedScopeException on Device Rotation with koinInject #1773

gecko10000 opened this issue Jan 29, 2024 · 5 comments

Comments

@gecko10000
Copy link

Describe the bug
When using koinInject() in a Composable, rotating the device causes a ClosedScopeException and crashes the application.

To Reproduce
Run this minimal reproducible example and rotate the device.

Expected behavior
The rotation should succeed and the application should continue running.

Koin module and version:
koin-android:3.5.3
koin-androidx-compose:3.5.3

@arnaudgiuliani arnaudgiuliani added this to the compose-3.5.4 milestone Jan 30, 2024
@arnaudgiuliani arnaudgiuliani self-assigned this Jan 30, 2024
@arnaudgiuliani arnaudgiuliani added the status:checking currently in analysis - discussion or need more detailed specs label Jan 30, 2024
@arnaudgiuliani
Copy link
Member

Thanks for your feedback 👍

@hoc081098
Copy link

hoc081098 commented Feb 6, 2024

@gecko10000 try wrapping the composable with KoinContext { ... }

@gecko10000
Copy link
Author

That fixes it, but it would be helpful to mention in the documentation, probably around here. I assumed androidContext(this@MainActivity) would be enough in the startKoin block (since it mostly worked).

@arnaudgiuliani arnaudgiuliani added documentation and removed status:checking currently in analysis - discussion or need more detailed specs labels Feb 15, 2024
@arnaudgiuliani
Copy link
Member

Cool. I'll update the documentation 👍

@arnaudgiuliani
Copy link
Member

Doc added 👍

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

No branches or pull requests

3 participants