-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
younari
committed
Dec 2, 2017
1 parent
e1d8fa5
commit d28ba5c
Showing
4 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// DisposeBagController.swift | ||
// RxTest | ||
// | ||
// Created by 김기윤 on 02/12/2017. | ||
// Copyright © 2017 leonard. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import RxCocoa | ||
import RxSwift | ||
|
||
class DisposeBagController: UIViewController { | ||
|
||
@IBOutlet weak var progressLabel: UILabel! | ||
@IBOutlet weak var disposeBagBtn: UIButton! | ||
|
||
var disposeBag: DisposeBag = DisposeBag() | ||
var testDisposeBag: DisposeBag = DisposeBag() | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
bind() | ||
} | ||
} | ||
|
||
extension DisposeBagController { | ||
|
||
func bind() { | ||
Observable<String>.create { (observer) -> Disposable in | ||
observer.onNext("HELLOWORLD") | ||
return Disposables.create { | ||
print("Disposed in Create") | ||
} | ||
}.subscribe( | ||
onNext: { text in | ||
self.progressLabel.text = text | ||
}, onDisposed: { | ||
print("Disposed in subscribe") | ||
}).disposed(by: testDisposeBag) | ||
|
||
disposeBagBtn.rx.tap.asObservable().subscribe( | ||
onNext: { [weak self] _ in | ||
self?.testDisposeBag = DisposeBag() | ||
}).disposed(by: disposeBag) | ||
} | ||
|
||
} |
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