Skip to content

RFE: Real providers (classes) #129

@arantius

Description

@arantius

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions