Last active
April 11, 2018 07:17
-
-
Save rajajawahar/1867b933d45a0162e92f2df11a918e2e to your computer and use it in GitHub Desktop.
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
import UIKit | |
import RxSwift | |
import RxCocoa | |
import Alamofire | |
class ViewController: UIViewController { | |
let disposeBag = DisposeBag() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
zipsample() | |
} | |
private func zipSample() { | |
let dummyParameter = 1 | |
Observable.zip(firstAPICall(), secondAPICall()) { ($0, $1) } | |
.subscribe(onNext: { response1, response2 in | |
print(response1, response2, separator:"\n") | |
}).addDisposableTo(disposeBag) | |
} | |
private func firstAPICall() ->Observable<String>{ | |
return Observable.create({ (observer) -> Disposable in | |
observer.onNext("First") | |
observer.onCompleted() | |
return Disposables.create() | |
}) | |
} | |
private func secondAPICall() ->Observable<String>{ | |
return Observable.create({ (observer) -> Disposable in | |
observer.onNext("Second") | |
observer.onCompleted() | |
return Disposables.create() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment