Created
July 9, 2019 02:40
-
-
Save GeekTree0101/3f72d406f6903c67a66d9548afcfffe1 to your computer and use it in GitHub Desktop.
No Archtecture
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
class TestViewController { | |
let userInputView = InputView() | |
let displayOutputView: OutputView() | |
func bind() { | |
let state = Presenter.shared.state(type: OutputViewState.self, id: 1) | |
state.map { $0.title }.bind(to: displayOutputView.rx.title).disposed(by: bag) | |
} | |
} | |
class Presenter { | |
static let shared = Presenter.init() | |
// share state | |
func state<T: ViewStateType>(type: T.Type, id: Identifier) -> Observable<T> { ... } | |
// dispatch viewState | |
func dispatch<T: ViewStateType>(_ target: T, qos: DispatchQosClass) { ... } | |
} | |
protocol Identifier { | |
func asIdentifier() -> String | |
} | |
extension Int: Identifier { | |
func asIdentifier() -> String { | |
return "\($0)" | |
} | |
} | |
extension String: Identifier { | |
func asIdentifier() -> String { | |
return self | |
} | |
} | |
protocol ViewStateType { | |
var id: Identfier { get } | |
} | |
struct OutputViewState: ViewStateType { | |
var id: Identfier | |
var title: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment