I have an Observable<Bool> that emits true when an operation begins and false when it ends.  I'd like to show a message while the operation is in progress, but only if it takes longer than two seconds to begin.  Is there a way I can create an observable that I can bind my message to?  Any help much appreciated!
If you switchMap (a flatMap where when a second item is emitted from the source the subscription to the original observable is unsubscribed and the subscription moves to the next) you could do something like this:
Note switchMap is 'switchLatest' in RxSwift.
Could become something like this:
booleanObservable
    .map { inProgress -> Observable<Bool> in
        if inProgress {
            return Observable.just(true).delay(time: 2)
        } else {
            return Observable.just(false)
        }
     }
    .switchLatest()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With