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

Question on resolving with Tags #165

Closed
vander2675 opened this issue Jul 5, 2017 · 5 comments
Closed

Question on resolving with Tags #165

vander2675 opened this issue Jul 5, 2017 · 5 comments

Comments

@vander2675
Copy link

Hey, first of all: It's a really great Framework you provide. Thank you very much for it!

And to the question:
Is the handing through of the tag only possible when using AutoWiring ?
Or is it also possible when using registration like this:

            container.register(.unique) {
                try Load<Chapter, Party>(request: container.resolve(), insert: container.resolve(), save: container.resolve()) as Load<Chapter, Party>
            }

Or do I have to register it this way?

            container.register(.unique) {
                try Load<Chapter, Party>(request: $0 as GenericApiRequest<Party>, insert: $1 as BatchInsert<Chapter, Party>, save: $3 as Save)
            }

Second question:

Is registering with :

            container.register(.unique, type: Load<Media, Chapter>.self, tag: nil, factory: Load<Media, Chapter>.init)

Using AutoWiring?

Thanks very much in advance.

@ilyapuchka
Copy link
Collaborator

You can get a tag from context object https://github.com/AliSoftware/Dip/wiki/Dependency-container-context, thats what autowiring does under the hood.

@vander2675
Copy link
Author

Thanks for the quick response. Is Autowiring Constraint to an maximum number of Constructor dependencies?

@ilyapuchka
Copy link
Collaborator

yes, the constraint is not on autowiring, it is on registration methods (you can add your own but it is not advised)

@vander2675
Copy link
Author

Ah I see. This was my problem. I will refactor my architecture here. Thank you!

@ilyapuchka
Copy link
Collaborator

Regarding you second question - autowiring is a feature to resolve dependencies of constructor without resolving them explicitly in registered factory or manually and passing as parameters to resolve method. So if you resolve this type with resolve it will use autowiring. More on that in docs in wiki.

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

2 participants