Skip to content

Instantly share code, notes, and snippets.

@andreaslydemann
Created January 29, 2019 06:37
Show Gist options
  • Select an option

  • Save andreaslydemann/2b0ba75e35f847a8a45de1dd2878a3ab to your computer and use it in GitHub Desktop.

Select an option

Save andreaslydemann/2b0ba75e35f847a8a45de1dd2878a3ab to your computer and use it in GitHub Desktop.
import RxSwift
let disposeBag = DisposeBag()
let xmenMovies = Observable.of("First Class", "Days of Future Past", "Apocalypse")
let imdbRatings = Observable.of(7.7, 8.0, 7.0)
Observable.combineLatest(xmenMovies, imdbRatings) { movie, rating in
"\(movie) - \(rating)"
}
.subscribe(onNext: {
print($0)
})
.disposed(by: disposeBag)
// Output:
// First Class - 7.7
// Days of Future Past - 7.7
// Days of Future Past - 8.0
// Apocalypse - 8.0
// Apocalypse - 7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment