Last active
July 4, 2018 04:01
-
-
Save alfian0/001dcf4a128d1741ec20f85a417dccf6 to your computer and use it in GitHub Desktop.
Contract with singleton
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
| final class ViewModel: ViewModelType { | |
| var input: Input | |
| var output: Output! | |
| struct Input {} | |
| struct Output {} | |
| static var shared: ViewModel { | |
| let viewModel = ViewModel() | |
| viewModel.transform() | |
| return viewModel | |
| } | |
| private init() { | |
| input = Input() | |
| } | |
| private func transform() { | |
| self.parser() | |
| output = Output() | |
| } | |
| private func parser() { | |
| } | |
| } |
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 ViewModelType { | |
| associatedtype Input | |
| associatedtype Output | |
| func transform(input: Input) -> Output | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment