Last active
November 19, 2018 18:04
-
-
Save vaderdan/cfd9ef853f123143e580ec2e3664a8c1 to your computer and use it in GitHub Desktop.
Sourcery Model protocols generating
This file contains 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
import RxSwift | |
import Action | |
import UIKit | |
{% for type in types.implementing.AutoModel %} | |
// MARK: {{ type.name }} | |
protocol {{ type.name }}Input { | |
{% for variable in type.variables %} | |
{% if variable.annotations.input %} | |
var {{ variable.name }}: {{ variable.typeName }} { get } | |
{% endif %} | |
{% endfor %} | |
{% for method in type.methods %} | |
{% if method.annotations.input %} | |
func {{ method.name }} | |
{% endif %} | |
{% endfor %} | |
} | |
protocol {{ type.name }}Output { | |
{% for variable in type.variables %} | |
{% if variable.annotations.output %} | |
var {{ variable.name }}: {{ variable.typeName }} { get } | |
{% endif %} | |
{% endfor %} | |
} | |
protocol {{ type.name }}Type { | |
var inputs: {{ type.name }}Input { get } | |
var outputs: {{ type.name }}Output { get } | |
} | |
extension {{ type.name }}: {{ type.name }}Type, {{ type.name }}Input, {{ type.name }}Output { | |
// MARK: Inputs & Outputs | |
var inputs: {{ type.name }}Input { return self } | |
var outputs: {{ type.name }}Output { return self } | |
} | |
{% endfor %} | |
This file contains 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 MenuViewCellModelInput { | |
var detailsAction: Action<Observable<Menu>, Void> { get } | |
} | |
protocol MenuViewCellModelOutput { | |
var title: Observable<String>! { get } | |
var subtitle: Observable<String>! { get } | |
var count: Observable<Int>! { get } | |
} | |
protocol MenuViewCellModelType { | |
var inputs: MenuViewCellModelInput { get } | |
var outputs: MenuViewCellModelOutput { get } | |
} | |
extension MenuViewCellModel: MenuViewCellModelType, MenuViewCellModelInput, MenuViewCellModelOutput { | |
// MARK: Inputs & Outputs | |
var inputs: MenuViewCellModelInput { return self } | |
var outputs: MenuViewCellModelOutput { return self } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment