Skip to content

Commit

Permalink
Added convenience init so you can initialize VIPER modules with code …
Browse files Browse the repository at this point in the history
…created View Controllers (without .xib).
  • Loading branch information
dresetnic committed Jul 26, 2019
1 parent 2667068 commit 31d88e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion swifty_viper/Code/Configurator/configurator.swift.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class {{ module_info.name }}ModuleConfigurator {
func configureModuleForViewInput<UIViewController>(viewInput: UIViewController) {

if let viewController = viewInput as? {{ module_info.name }}ViewController {
configure(viewController)
configure(viewController: viewController)
}
}

Expand Down
9 changes: 8 additions & 1 deletion swifty_viper/Code/Configurator/initializer.swift.liquid
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

//
// {{ prefix }}{{ module_info.name }}{{ module_info.file_name }}
// {{ module_info.project_name }}
Expand All @@ -16,7 +17,13 @@ class {{ module_info.name }}ModuleInitializer: NSObject {
override func awakeFromNib() {

let configurator = {{ module_info.name }}ModuleConfigurator()
configurator.configureModuleForViewInput({{ module_info.name | downcase }}ViewController)
configurator.configureModuleForViewInput(viewInput: {{ module_info.name | downcase }}ViewController)
}

convenience init({{ module_info.name | downcase }}ViewController: {{ module_info.name }}ViewController) {
self.init()
let configurator = {{ module_info.name }}ModuleConfigurator()
configurator.configureModuleForViewInput(viewInput: {{ module_info.name | downcase }}ViewController)
}

}

0 comments on commit 31d88e6

Please sign in to comment.