Skip to content

Instantly share code, notes, and snippets.

@alfian0
Last active July 4, 2018 04:01
Show Gist options
  • Select an option

  • Save alfian0/001dcf4a128d1741ec20f85a417dccf6 to your computer and use it in GitHub Desktop.

Select an option

Save alfian0/001dcf4a128d1741ec20f85a417dccf6 to your computer and use it in GitHub Desktop.
Contract with singleton
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() {
}
}
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