Created
August 22, 2018 14:27
-
-
Save AvatarHurden/9603d5c21a97a315c53235fa133558a2 to your computer and use it in GitHub Desktop.
PoppableVC
This file contains 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
protocol Bindable { | |
associatedtype ViewModel | |
var viewModel: ViewModel! { get set } | |
func bindToViewModel() | |
} | |
protocol PoppableVC { | |
associatedtype Parent | |
} | |
protocol PoppableVM { | |
var action: CocoaAction { get } | |
} | |
extension UINavigationControllerDelegate where Self: UIViewController, Self: Bindable & PoppableVC, Self.ViewModel: PoppableVM { | |
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { | |
if viewController is Self.Parent { | |
self.viewModel.action.execute(()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment