Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Source Code Generator for Team Development/code...

Source Code Generator for Team Development/code-generator-for-team-development

Otemachi.swift x Kyobashi.swift #01

Taketo Yoshida

August 08, 2017
Tweet

More Decks by Taketo Yoshida

Other Decks in Programming

Transcript

  1.  view_model.swift.liquid SomeViewModel.swift // // {{ module_info.file_name }} // {{

    module_info.project_name }} // // Created by {{ developer.name }} on {{ date }}. // Copyright © {{ year }} {{ developer.company }}. // All rights reserved. // import Foundation import RxSwift import RxCocoa protocol {{ module_info.name }}ViewModel: class { var isLoading: Driver<Bool> { get } var hasError: Driver<Bool> { get } } // // SomeViewModelViewModel.swift // Nikkei // // Created by Taketo Yoshida on 23/02/2017. // Copyright © 2017 nikkei. // All rights reserved. // import Foundation import RxSwift import RxCocoa protocol SomeViewModel: class { var isLoading: Driver<Bool> { get } var hasError: Driver<Bool> { get } }
  2.  view_model.swift.liquid protocol {{ module_info.name }}ViewModel: class { /** Output

    Definition of ViewModel */ var isLoading: Driver<Bool> { get } var hasError: Driver<Bool> { get } var toastMessage: Driver<String> { get } /** Input Definition of ViewModel */ }
  3.  view_model.swift.liquid final class {{ module_info.name }}ViewModelImpl: {{ module_info.name }}ViewModel

    { let disposeBag = DisposeBag() // output let isLoading: Driver<Bool> let hasError: Driver<Bool> let toastMessage: Driver<String> // input init(model: {{ module_info.name }}Model, wireframe: {{ module_info.name }}Wireframe, scheduler: SchedulerService = MainSchedulerService.shared) { self.isLoading = model.isLoading .asDriver(onErrorDriveWith: Driver.empty()) self.hasError = model.errors .map({ $0.isError }) .asDriver(onErrorDriveWith: Driver.empty()) self.toastMessage = model.errors .map({ $0.description }) .filterNil() .asDriver(onErrorDriveWith: Driver.empty()) } }