Skip to content

Instantly share code, notes, and snippets.

@danieljvdm
Last active May 16, 2016 19:36
Show Gist options
  • Save danieljvdm/82aae48dad733873bd71e2232dbeedc9 to your computer and use it in GitHub Desktop.
Save danieljvdm/82aae48dad733873bd71e2232dbeedc9 to your computer and use it in GitHub Desktop.
protocol Injectable {
associatedtype T
var viewModel: T! {get set}
mutating func inject(viewModel: T)
func assertDependencies()
}
extension Injectable {
func assertDependencies() {
assert(viewModel != nil)
}
mutating func inject(viewModel: T) {
self.viewModel = viewModel
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment