Created
October 18, 2019 09:19
-
-
Save nalexn/587757b6d184755c25b7b36069145a15 to your computer and use it in GitHub Desktop.
Article_002 https://nalexn.github.io/mvvm-state-redundancy/
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
class PodcastsViewController: UIViewController { | |
@IBOutlet weak var tableView: UITableView! | |
@IBOutlet weak var errorMessageLabel: UILabel! | |
@IBOutlet weak var indicatorView: UIActivityIndicatorView! | |
var viewModel: PodcastsViewModel! | |
var disposeBag = DisposeBag() | |
func viewDidLoad() { | |
super.viewDidLoad() | |
// ... | |
viewModel.isLoading.bind(to: indicatorView.rx.isAnimating).disposed(by: disposeBag) | |
viewModel.onError.subscribe(onNext: { [weak self] error in | |
self?.errorMessageLabel?.text = error.localizedDescription | |
}).disposed(by: disposeBag) | |
viewModel.podcasts.map { $0.count > 0 } | |
.bind(to: errorMessageLabel.rx.isHidden).disposed(by: disposeBag) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment