Skip to content

Instantly share code, notes, and snippets.

@kakajika
Last active February 27, 2018 05:23
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 kakajika/c12972ae9e4f6c2af4bdab02c993a2d8 to your computer and use it in GitHub Desktop.
Save kakajika/c12972ae9e4f6c2af4bdab02c993a2d8 to your computer and use it in GitHub Desktop.
RxSwift.ObservableType::isEmpty()
extension ObservableType {
func isEmpty() -> Single<Bool> {
return self
.take(1)
.map { _ in false }
.ifEmpty(switchTo: Observable.just(true))
.asSingle()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment