Skip to content

Instantly share code, notes, and snippets.

@andreaslydemann
Last active January 20, 2019 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreaslydemann/b665646ab01a65da7fbdd566660164fd to your computer and use it in GitHub Desktop.
Save andreaslydemann/b665646ab01a65da7fbdd566660164fd to your computer and use it in GitHub Desktop.
import RxSwift
let bestSellingAlbums = [
(title: "Thriller", salesInMillions: 93),
(title: "Eagles: Their Greatest Hits 1971-1975", salesInMillions: 41),
(title: "Hotel California", salesInMillions: 32),
(title: "Come on Over", salesInMillions: 29),
(title: "Led Zeppelin IV", salesInMillions: 29),
(title: "The Bodyguard Soundtrack", salesInMillions: 28),
(title: "Rumours", salesInMillions: 27),
(title: "Back in Black", salesInMillions: 26),
(title: "21", salesInMillions: 25),
(title: "Jagged Little Pill Year: 1995", salesInMillions: 24),
]
let disposeBag = DisposeBag()
Observable.from(bestSellingAlbums)
.skipWhile { album in
album.salesInMillions > 30
}
.subscribe(onNext: {
print($0)
})
.disposed(by: disposeBag)
// Output:
// (title: "Come on Over", salesInMillions: 29)
// (title: "Led Zeppelin IV", salesInMillions: 29)
// (title: "The Bodyguard Soundtrack", salesInMillions: 28)
// (title: "Rumours", salesInMillions: 27)
// (title: "Back in Black", salesInMillions: 26)
// (title: "21", salesInMillions: 25)
// (title: "Jagged Little Pill Year: 1995", salesInMillions: 24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment