Skip to content

Instantly share code, notes, and snippets.

@scottroemeschke
Created May 21, 2017 20:06
Show Gist options
  • Save scottroemeschke/d75286018d52b2d8806bc7a3cd755602 to your computer and use it in GitHub Desktop.
Save scottroemeschke/d75286018d52b2d8806bc7a3cd755602 to your computer and use it in GitHub Desktop.
kotlin extensions for kotlin komparisons: login details
inline fun <T> BehaviorRelay<T>.withInitIfEmpty(initializer: () -> Single<T>): Observable<T> {
if (hasValue()) return hide()
else return initializer.invoke().flatMapObservable {
accept(it)
hide()
}
}
fun <T> RxPaperBook.writeThenForward(key: String, value: T, consumer: Consumer<T>): Completable {
return write(key, value).doOnComplete { consumer.accept(value) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment