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

Proposal: lookupAll(type) #32

Open
davewasmer opened this issue Mar 11, 2017 · 0 comments
Open

Proposal: lookupAll(type) #32

davewasmer opened this issue Mar 11, 2017 · 0 comments

Comments

@davewasmer
Copy link

Really excited to find this library (h/t @knownasilya)

I'd love to use this in Denali, but I'd need one additional method on the container: a lookupAll(type) method. It would allow a consumer to lookup all the registrations for a given type. My suggestion would be to return an object keyed on the registrations' names or full specifiers, but an array would work just as well for me.

One potential sticking point would be for resolver-backed lookups, since the current approach is lazy (meaning that the container and resolver may not know the entire set of registrations available for a type when lookupAll is called). One potential solution would be to allow the resolver to supply an optional retrieveAll(type), and if the resolve doesn't define a retrieveAll (or perhaps it returns false), then the container would simply return whatever registrations it has (registry plus anything found from previous resolver lookups).

I'm also open to arguments that this is a bad idea - perhaps there's a better way to architect what I need (running initializer-style functions on everything of a certain eagerly loaded type).

Happy to PR my suggestion, but wanted to run it by you all first to get a 👍 / 👎

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