Skip to content

wpompei-shared/MVVMViewController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

MVVMViewController

MVVMViewController base class

Base class to clean view controller when applying MVVM pattern using RxSwift.

For more details, please look at UIViewController full initialization in MVVM

Usage

class ViewModel {
    
    let request = PublishSubject<String>()
    func askForSomething() {
        
    }
}

class ViewController: MVVMViewController<ViewModel> {
    
    
    let label = UILabel()
    override func viewDidLoad() {
        setupRx()
    }
    
    func setupRx() {
        // viewModel already defined in MVVMViewController superclass
        // viewModel type is ViewModel as specified in MVVMViewController<ViewModel> 
        viewModel.request 
        .bind(to: label.rx.text)
        .disposed(by: disposeBag) // dispose bag already defined in MVVMViewController superclass
    }
}

Feel free to tailor the code to your needs.

About

MVVMViewController base class.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages