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
| _ = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance) | |
| .subscribe(onNext: { _ in | |
| print("Rx Resource Count: \(RxSwift.Resources.total)") | |
| }) |
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 MyCell: UITableViewCell { | |
| private var disposeBag = DisposeBag() | |
| override func prepareForReuse() { | |
| super.prepareForReuse() | |
| disposeBag = DisposeBag() // Destroys and disposes of old subscriptions, creates a new cell | |
| } | |
| } |
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
| let dataSource = RxTableViewSectionedReloadDataSource<CustomSection>( | |
| configureCell: { [weak self] _, tableView, indexPath, viewModel in | |
| guard let cell = tableView.dequeueReusableCell(withIdentifier: CustomTableViewCell.reuseIdentifer, for: indexPath) as? CustomTableViewCell else { return UITableViewCell() } | |
| cell.viewModel = viewModel | |
| cell.disposeBag = self?.disposeBag // Bad idea, don't do this! | |
| return cell | |
| }) |
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 MyView: UIView { | |
| . | |
| . | |
| . | |
| init() { | |
| self.rx | |
| .swipeGesture(.up) | |
| .when(.ended) | |
| .map { $0.view?.frame } | |
| .bind(to: viewModel.viewDidSwiped) |
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 MyView: UIView { | |
| . | |
| . | |
| . | |
| init() { | |
| self.rx | |
| .swipeGesture(.up) | |
| .when(.ended) | |
| .subscribe { [weak self] swipeGestureRecognizer in | |
| guard let self = self else { return } |
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 MyView: UIView { | |
| . | |
| . | |
| . | |
| init() { | |
| self.rx | |
| .swipeGesture(.up) | |
| .when(.ended) // Observable<UISwipeGestureRecognizer> | |
| .bind(to: viewModel.viewDidSwiped) | |
| .disposed(by: bag) |
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
| viewModel.frame | |
| .drive(onNext: { [weak self] rect in | |
| UIView.animate(withDuration: 0.3) { [weak self] in | |
| self?.frame = rect | |
| } | |
| }) | |
| .disposed(by: disposeBag) |
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
| service | |
| .flatMap { [weak self] text -> Observable<Void> in | |
| guard let self = self else { return .empty() } | |
| . | |
| . | |
| . | |
| return self.network | |
| .request(url: url) | |
| .do(onNext: { response in | |
| self.status.value = .success(response) |
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
| viewModel.data | |
| .drive(onNext: { [weak self] someData in | |
| self?.display(data) | |
| }) | |
| .disposed(by: bag) |
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
| viewModel.data | |
| .drive(onNext: { someData in | |
| self?.display(someData) | |
| }) | |
| .disposed(by: bag) |
NewerOlder