Login view managed with RxSwift approach with input and output.
- iOS 11.0+ / macOS 10.15+ / Xcode 12.0+
- Swift 5.0+
pod 'RxSwift', '~> 6.2.0'
pod 'RxCocoa', '~> 6.2.0'
pod 'RxSwiftExt', '~> 6.0.0'
Example of a login view with architecture MVVM in which we implement reactive programming and we want to enable the button view when the user and password characters are greater than 3 in the textfield.
func bindViewModel() {
usernameTextfield
.rx.text.map { $0 ?? "" }
.debug("username")
.bind(to: viewModel.input.username)
.disposed(by: disposeBag)
passwordTextfield
.rx.text.map { $0 ?? "" }
.debug("password")
.bind(to: viewModel.input.password)
.disposed(by: disposeBag)
viewModel
.output.login
.debug("button")
.drive(loginButton.rx.isEnabled)
.disposed(by: disposeBag)
}
This method is subscribed and notified when there is a change that has been previously initialized in the viewModel.
