let password = PublishSubject<String>()
let repeatedPassword = PublishSubject<String>()
_ = Observable.combineLatest(password, repeatedPassword) { "\($0), \($1)" }
.subscribe(onNext: { print("onNext: ", $0) })
password.onNext("a")
password.onNext("ab")
repeatedPassword.onNext("A")
repeatedPassword.onNext("AB")
repeatedPassword.onNext("ABC")
onNext: ab, A
onNext: ab, AB
onNext: ab, ABC
let intSubject = PublishSubject<Int>()
let stringSubject = PublishSubject<String>()
_ = Observable.zip(intSubject, stringSubject) { "\($0) \($1)" }
.subscribe(onNext: { print($0) })
intSubject.onNext(1)
intSubject.onNext(2)
stringSubject.onNext("A")
stringSubject.onNext("B")
stringSubject.onNext("C")
stringSubject.onNext("D")
intSubject.onNext(3)
intSubject.onNext(4)
1 A
2 B
3 C
4 D