-
-
Save takasek/6b5b42814a5adc1687e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Swinject | |
class BundleSegue: InjectionSegue { | |
typealias Source = BundlesViewController | |
typealias Destination = BundleViewController | |
override func inject() { | |
destinationController.viewModel = resolver.resolve(BundleViewModelType.self) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Swinject | |
class InjectionSegue: UIStoryboardSegue, InjectionSegueType { | |
typealias Source = UIViewController | |
typealias Destination = UIViewController | |
func inject() { | |
} | |
override func perform() { | |
self.inject() | |
super.perform() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Swinject | |
protocol InjectionSegueType { | |
typealias Source: UIViewController | |
typealias Destination: UIViewController | |
var sourceController: Source { get } | |
var destinationController: Destination { get } | |
var resolver: Resolvable { get } | |
func inject() | |
} | |
extension InjectionSegueType where Self: UIStoryboardSegue { | |
var sourceController: Source { | |
return sourceViewController as! Source | |
} | |
var destinationController: Destination { | |
return destinationViewController as! Destination | |
} | |
var resolver: Resolvable { | |
return assembler.resolver | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment