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

RFE: Real providers (classes) #129

Open
arantius opened this issue Dec 15, 2020 · 0 comments
Open

RFE: Real providers (classes) #129

arantius opened this issue Dec 15, 2020 · 0 comments

Comments

@arantius
Copy link

Adopted Fruit for a recent project, have been a big Guice user in the past. There was a learning curve but I'm overall very happy with it. Big thanks.

The one thing that I desperately miss (from Guice) is providers. I don't want a lambda to re-implement every place (i.e. unit test) I depend on the thing, I don't want to define a whole bunch of global level Component functions. (I tried building everything from Components like the docs suggest at first, it just does not work for me, it gets in the way.)

I just want to be able to .bind<ThingProvider, ThingProviderImpl>(), where ThingProvider defines an (e.g.) public: T Get() (implements FruitProviderInterface?), and then be able to depend on a concrete T anywhere I need it. All the complexity of building that thing is in one place, and I can test it. And I can define a simpler ThingProviderFake for tests of everything that (transitively) depends upon it instead, and bind it with just one line.

To date I've been implementing my providers, and everywhere I depend upon them I manually Get() the T out, turning the provider into the instance. (Except in the one case where I store the provider, because other things need to happen before I can Get() from it.) Would be nice to eliminate that boilerplate.

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

No branches or pull requests

1 participant