Find out how to manage threads in RxSwift and get an introduction to using timing operators to filter consecutive input.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4743-beginning-rxswift/lessons/19
Find out how to manage threads in RxSwift and get an introduction to using timing operators to filter consecutive input.
Hi Scott,
Great tutorials! I am learning a lot. One question, How is it possible to use take(5.0, MainScehdular.instance) operator with a CocoaAction?
@scotteg Can you please help with this when you get a chance? Thank you - much appreciated! :]
Thanks. Hereβs an example of using take
with a 5 second timer:
.take(5.0, scheduler: MainScheduler.instance)
.subscribe(onNext: { _ in
print("You tapped the button within 5 seconds")
})
.disposed(by: disposeBag)
Schedulers have been refactored in RxSwift 5 to deprecate the usage of TimeInterval
in favor of DispatchTimeInterval
.
.take(5.0, scheduler: MainScheduler.instance)
.take(.seconds(5), scheduler: MainScheduler.instance)
@rastislv Thank you for the heads up - much appreciated!