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

No longer possible to get objects from a scope in Java code #451

Closed
alexbchr opened this issue May 14, 2019 · 5 comments
Closed

No longer possible to get objects from a scope in Java code #451

alexbchr opened this issue May 14, 2019 · 5 comments
Labels
status:accepted accepted to be developed type:issue
Milestone

Comments

@alexbchr
Copy link

Is your feature request related to a problem? Please describe.
As of Koin 2.0.0-RC2, it was possible to pass a Scope instance to KoinJavaComponent.get() to retrieve an instance associated to a scope. However, as of 2.0.0-GA2, KoinJavaComponent.get() no longer allows a scope as a parameter, making it impossible to inject instances associated to a scope in Java code.

Describe the solution you'd like
A simple and elegant solution would be to prevent this breaking change by putting back the scope parameter in KoinJavaComponent.get() (and probably inject() function too).

Describe alternatives you've considered
For now, I created my own function which converts a Java class to a KClass instance, making it possible to call the usual get() function from Java code.

Thanks for your help! It would be cool if this can make its way to the release of 2.0.0!

@arnaudgiuliani
Copy link
Member

get() and inject() with scope parameter is back 👍
Please try 2.0.0-GA3

@alexbchr
Copy link
Author

I can confirm that it works as intended! Thanks for the quick fix!

@arnaudgiuliani
Copy link
Member

nice

@alexbchr
Copy link
Author

There seems to be a regression with the 2.0.0 release, as this was fixed in 2.0.0-GA3 and 2.0.0-GA4, but in 2.0.0 and 2.0.1, the KoinJavaComponent does not accept any scope parameter, although it is mentioned in the changelog of 2.0.0 this issue was fixed.

I just checked the code of KoinJavaComponent in master, and there is no more scope parameter.

@alexbchr alexbchr reopened this Jun 14, 2019
@arnaudgiuliani
Copy link
Member

you have to use the scope object directly, not passing it by param

@arnaudgiuliani arnaudgiuliani modified the milestones: 2.0.0, 2.0.2 Jul 15, 2019
@arnaudgiuliani arnaudgiuliani modified the milestones: 2.0.2, 2.1.0 Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:accepted accepted to be developed type:issue
Projects
None yet
Development

No branches or pull requests

2 participants