Skip to content

Instantly share code, notes, and snippets.

@s4cha
Created July 26, 2018 12:22
Show Gist options
  • Select an option

  • Save s4cha/541fe18cdd197a41700d4adc6a37bca8 to your computer and use it in GitHub Desktop.

Select an option

Save s4cha/541fe18cdd197a41700d4adc6a37bca8 to your computer and use it in GitHub Desktop.
Native Swift Dependency Inversion
protocol <#Depencency#> {
func foo()
}
protocol Has<#Depencency#> {
func get<#Depencency#> () -> <#Depencency#>
}
// Implementation
extension Has<#Depencency#> {
func get<#Depencency#> () -> <#Depencency#> {
return <#Implementation#>
}
}
class <#Implementation#>: <#Depencency#> {
func foo() {
// Implementation details
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment