-
Notifications
You must be signed in to change notification settings - Fork 506
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
Container with parent assembly #50
Container with parent assembly #50
Conversation
/// Instantiates a `Container` with its parent `Assembler`. | ||
/// | ||
/// - Parameter parentAssembly: The parent `Assembler`. | ||
public convenience init(parentAssembly: Assembler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid Docs Violation: Documented declarations should be valid. (valid_docs)
Thank you for your pull request with the enhancement and unit test👍 I would like to merge it. Before merging the PR, I have a small suggestion. I think the requirement can be achieved by adding initializers to
As discussed in PR #35, I would like to keep |
This pull request relates to the following StackOverflow question: |
@mowens, do you have any comment? |
I like the idea of keeping the This way access to the actual container is still restricted to only the
|
Thank you @mowens😃 |
@yoichitgy @mowens Great idea, guys. Dagger (dependency injection for Java) has similar structure. I will reopen pull request (in fact, I have to revert my commits and start from scratch). Lets keep this one open if other people have suggestions :) |
Thanks @Nikita2k for accepting our idea. I think you can force-push to the same branch to update this PR without creating a new PR😀
|
/// - parameter parentAssembler: the baseline assembler | ||
/// - parameter propertyLoaders: a list of property loaders to apply to the container | ||
/// | ||
public init(assemblies: [AssemblyType], parentAssembler: Assembler, propertyLoaders: [PropertyLoaderType]? = nil) throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid Docs Violation: Documented declarations should be valid. (valid_docs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid Docs Violation: Documented declarations should be valid. (valid_docs)
@yoichitgy I can't push to your repo:) We usually keep unsuccessful PR too, but if you like, I pushed changes here |
Thank you @Nikita2k for updating the PR. Now I see your intention creating a new PR. I just don't have a policy to keep PRs before editing, so your update to this PR is ok. I will investigate the messages from Hound CI, then will merge your PR. I've not updated my SwiftLint to 0.5.5 yet, and don't know why the code docs violating the lint. |
Hound CI looks still using SwiftLint 0.4.0. This PR branch in my local environment has no violation with SwiftLint 0.4.0. It looks Hound CI incorrectly reported in this PR. |
Thanks @Nikita2k for the enhancement. I was wondering whether the initializers should be |
Container with parent assembly
This PR contains changes & tests for creating container with parent assembly.
Why?
Assume you have
ApiManager
,ViewController1
andViewController2
in TabBar application. Both controllers asks API for some data. To implement this scheme we can create the following container hierarchy:RootContainer
(where ApiManager lives)Controller1Container
(all specific dependencies for VC1)Controller2Container
(all specific dependencies for VC2)Later you decide to make a new feature: background upload (or tracking user location, etc). You have bunch of classes, that are responsible for that. Now you have two options:
BackgroundUploadContainer
and put all dependencies thereRootContainer
Both of them are not so good and shiny:
RootContainer
will be soon a 10-screen-height file with lots of dependenciesSolutions?
We can have a
RootAssembly
=RootContainer
+BackgroundUploadContainer
. But with that solution it's impossible to haveController1Container
knowing about both of them (no container constructor acceptsAssembler
).I propose to add such a constructor.