Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import RxSwift
let disposeBag = DisposeBag()
let oldXmenMovies = PublishSubject<String>()
let newXmenMovies = PublishSubject<String>()
let xmenMovies = Observable.of(oldXmenMovies, newXmenMovies)
xmenMovies.merge()
.subscribe(onNext: { movie in
print(movie)
})
.disposed(by: disposeBag)
oldXmenMovies.onNext("X-Men")
oldXmenMovies.onNext("X-Men United")
newXmenMovies.onNext("First Class")
oldXmenMovies.onNext("The Last Stand")
newXmenMovies.onNext("Days of Future Past")
// Output:
// X-Men
// X-Men United
// First Class
// The Last Stand
// Days of Future Past
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment