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

Allow injection of multibinding providers #51

Open
poletti-marco opened this issue Jun 10, 2017 · 2 comments
Open

Allow injection of multibinding providers #51

poletti-marco opened this issue Jun 10, 2017 · 2 comments
Milestone

Comments

@poletti-marco
Copy link
Contributor

E.g. we could define a fruit::MultibindingProvider<T> class that allows to get a vector of the multibindings for that type, and allow injecting that as a dependency.
This will have the caveat that injection dependency loops involving a MultibindingProvider will only be detected at runtime.

To print the actual loop, maybe we can have an on-this-error-only, slow code path where we walk the injection graph at runtime, looking for in-progress injections, to find the loop; then we can print a more useful error message with the types involved in the loop. TBD if there's enough information available to determine the loop.

@poletti-marco poletti-marco added this to the Fruit 2.1.1 milestone Jun 10, 2017
@poletti-marco poletti-marco modified the milestones: 3.1.0, Fruit 2.1.1 Jul 15, 2017
@Inujel
Copy link

Inujel commented Oct 3, 2022

Is this the missing piece to achieve something like this?

class Service{};
class A : public Service{};
class B : public Service{};

class App
{
public:
   INJECT(App(std::vector<Service*> services)) {}
};

fruit::Component<App> app_component()
{
   return fruit::createComponent()
		.addMultibinding<Service, A>()
		.addMultibinding<Service, B>();
}

Or is it already doable and I'm missing something?

@poletti-marco
Copy link
Contributor Author

Hi, sorry for the delay.
Yes, exactly.
ATM you need to get the multi binders from the injector directly then pass them down to the method/object that needs them.

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

2 participants