Last active
January 20, 2019 10:43
-
-
Save magi82/a79bb41d3ce2cb6f668e0fa8880d6015 to your computer and use it in GitHub Desktop.
blog_rxswift_03
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<String>.just("test") | |
| .subscribe { event in | |
| switch event { | |
| case .next(let value): | |
| print(value) | |
| case .error(let error): | |
| print(error) | |
| case .completed: | |
| print("completed") | |
| } | |
| } |
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(1, scheduler: MainScheduler.instance) | |
| .take(10) | |
| .subscribe(onNext: { value in | |
| print(value) | |
| }, onError: { error in | |
| print(error) | |
| }, onCompleted: { | |
| print("onCompleted") | |
| }, onDisposed: { | |
| print("onDisposed") | |
| }) |
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(1, scheduler: MainScheduler.instance) | |
| .take(10) | |
| .subscribe(onNext: { value in | |
| print(value) | |
| }, onError: { error in | |
| print(error) | |
| }, onCompleted: { | |
| print("onCompleted") | |
| }, onDisposed: { | |
| print("onDisposed") | |
| }) | |
| DispatchQueue.main.asyncAfter(deadline: .now() + 3) { | |
| UIApplication.shared.keyWindow?.rootViewController = nil | |
| } |
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 disposable = Observable<Int>.interval(1, scheduler: MainScheduler.instance) | |
| .take(10) | |
| .subscribe(onNext: { value in | |
| print(value) | |
| }, onError: { error in | |
| print(error) | |
| }, onCompleted: { | |
| print("onCompleted") | |
| }, onDisposed: { | |
| print("onDisposed") | |
| }) | |
| DispatchQueue.main.asyncAfter(deadline: .now() + 3) { | |
| disposable.dispose() | |
| } |
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
| import UIKit | |
| import RxSwift | |
| class CustomViewController: UIViewController { | |
| var disposeBag = DisposeBag() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| test() | |
| } | |
| deinit { | |
| print(“deinit CustomViewController”) | |
| } | |
| func test() { | |
| Observable<Int>.interval(1, scheduler: MainScheduler.instance) | |
| .take(10) | |
| .subscribe(onNext: { value in | |
| print(value) | |
| }, onError: { error in | |
| print(error) | |
| }, onCompleted: { | |
| print(“onCompleted”) | |
| }, onDisposed: { | |
| print(“onDisposed”) | |
| }) | |
| .disposed(by: disposeBag) | |
| DispatchQueue.main.asyncAfter(deadline: .now() + 3) { | |
| UIApplication.shared.keyWindow?.rootViewController = nil | |
| } | |
| } | |
| } |
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
| disposeBag = DisposeBag() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment