Beginning RxSwift - Part 19: Schedulers and | Ray Wenderlich Videos

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

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.

RxSwift 4.x:

.take(5.0, scheduler: MainScheduler.instance)

RxSwift 5.x:

.take(.seconds(5), scheduler: MainScheduler.instance)

@rastislv Thank you for the heads up - much appreciated!