Last active
February 27, 2018 05:23
-
-
Save kakajika/c12972ae9e4f6c2af4bdab02c993a2d8 to your computer and use it in GitHub Desktop.
RxSwift.ObservableType::isEmpty()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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