Created
May 20, 2016 23:00
-
-
Save gamako/1c52ef8eb19070138fcb35677e696475 to your computer and use it in GitHub Desktop.
This file contains 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 { | |
/** | |
throttleFirst | |
RxJava reference | |
http://reactivex.io/RxJava/javadoc/rx/Observable.html#throttleFirst(long,%20java.util.concurrent.TimeUnit,%20rx.Scheduler) | |
*/ | |
func throttleFirst(time: RxTimeInterval, scheduler: SchedulerType) -> Observable<E> { | |
let s = self.share() | |
return s | |
.throttle(time, scheduler: scheduler) | |
.map { _ in () } | |
.startWith() | |
.flatMapLatest{ _ in s.take(1) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment