Skip to content

Ability to pass arguments#62

Open
malkevych wants to merge 21 commits into
Swinject:masterfrom
SeductiveMobile:master
Open

Ability to pass arguments#62
malkevych wants to merge 21 commits into
Swinject:masterfrom
SeductiveMobile:master

Conversation

@malkevych
Copy link
Copy Markdown

With this improvements we can add ability to pass 3 arguments

@yoichitgy
Copy link
Copy Markdown
Member

Thanks @webslesar for the pull request👍 I'll check it after merging #46 to avoid conflict.

@yoichitgy
Copy link
Copy Markdown
Member

Can you add unit tests?

@malkevych
Copy link
Copy Markdown
Author

Yes

@Mackarous
Copy link
Copy Markdown

@yoichitgy Any plans for this?

@matcartmill-old
Copy link
Copy Markdown

+1 for this. Would love to have this ability.

Copy link
Copy Markdown
Member

@jakubvano jakubvano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long to review this.
In general it is heading in the right direction 👍 , we just need to remove the repeated code and clean up the API. If you need some help setting up code generation, feel free to ask 😉
And as @yoichitgy pointed out earlier, adding unit tests to such nontrivial functionality would be very useful.

Comment thread README.md
name: "Animals", bundle: nil, container: container)
let firstArg: Int = 5
let secondArg: SomeValue = SomeValue()
let catController = sb.instantiateViewController(withIdentifier: "SomeIdentifier", arg1: firstArg, arg2: secondArg) as! AnimalViewController
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more consistent to have API similar to Swinject, i.e.
instantiateViewController(withIdentifier: "SomeIdentifier", arguments: firstArg, secondArg)


extension SwinjectStoryboard {

#if os(iOS) || os(tvOS)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to extend this for OSX as well

for child in viewController.childViewControllers {
injectDependency(to: child)
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of repeated code between methods with different arguments. Can we reuse this code somehow? Alternatively we can generate this similarly to how it is done in Swinject (see. Container.Arguments.erb)

}

}
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this file should probably be generated (see. Resolver.erb)

s.license = 'MIT'
s.author = 'Swinject Contributors'
s.source = { :git => "https://github.com/Swinject/SwinjectStoryboard.git", :tag => s.version.to_s }
s.source = { :git => "https://github.com/SeductiveMobile/SwinjectStoryboard.git", :tag => s.version.to_s }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 😉

@andreybog
Copy link
Copy Markdown

Fixed the issue of arguments capturing while using 'storyboardInitCompletedArgs' family methods.

# Conflicts:
#	Cartfile.resolved
#	SwinjectStoryboard.podspec
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

Successfully merging this pull request may close these issues.

7 participants