Last active
May 30, 2017 21:09
-
-
Save dangthaison91/f17df36c4b2dd97e1b7f0b0a109a80fc to your computer and use it in GitHub Desktop.
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
let originalObservable = getObservable() | |
let defaultValueIfIdle = Observable<Int>.interval(5, scheduler: SerialDispatchQueueScheduler(qos: .background)) | |
.mapTo("defaultValue") | |
let observableWithDefaultValue = originalObservable | |
.flatMapLatest { item in | |
let currentItem = Observable.just(item) | |
return Observable.of(currentItem, defaultValueIfIdle).concat() | |
} | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment