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

Support Scope parameter in Activity and Fragment delegate methods. #2040

Open
mariusmorabosch opened this issue Oct 30, 2024 · 2 comments
Open
Labels
question Usage question

Comments

@mariusmorabosch
Copy link

mariusmorabosch commented Oct 30, 2024

The compose extensions allow you to inject a ViewModel while specifying a scope, but the activity and fragments one do not. They should both support the same parameters, otherwise one has to duplicate the source code to call resolveViewModel with a custom scope for fragments / activities.

Is there any reason why the fragment / activity do not support the scope parameter but the @composable ones do?

@arnaudgiuliani arnaudgiuliani added the question Usage question label Nov 18, 2024
@arnaudgiuliani
Copy link
Member

on activity/fragment you don't pass the scope explicitly, as you resolve things from it. This ActivityScope setup the scope you will use in the background: https://github.com/InsertKoinIO/koin/blob/main/projects/android/koin-android/src/main/java/org/koin/androidx/scope/ScopeActivity.kt#L35

@mariusmorabosch
Copy link
Author

@arnaudgiuliani What if you want to use a named scope though? Using the activity scope then everything is bound to the activity implicitly but if I want to have more than one scope on the same activity or just use a named scope to pass to child fragments and handle its lifecycle differently?

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

No branches or pull requests

2 participants