Skip to content

ruben-ml/MVVM-RxSwift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MVVM-RxSwift

Platform Language

Login view managed with RxSwift approach with input and output.

Requirements

  • iOS 11.0+ / macOS 10.15+ / Xcode 12.0+
  • Swift 5.0+

Architecture MVVM

Image text

RxSwift dependencies

pod 'RxSwift', '~> 6.2.0'
pod 'RxCocoa', '~> 6.2.0'
pod 'RxSwiftExt', '~> 6.0.0'

Usage

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.

Code

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors