Created
July 26, 2018 12:22
-
-
Save s4cha/541fe18cdd197a41700d4adc6a37bca8 to your computer and use it in GitHub Desktop.
Native Swift Dependency Inversion
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
| 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