Как установить RxTimeInterval для отката в RxSwift? - PullRequest
2 голосов
/ 08 июня 2019

Невозможно установить Rxtimeinterval для debounce в rxswift.Мой код ниже.Я получил это сообщение об ошибке «Невозможно преобразовать значение типа Double в ожидаемый тип аргумента RxTimeInterval (также известный как DispatchTimeInterval)»

searchBar
    .rx.text // Observable property thanks to RxCocoa
    .orEmpty // Make it non-optional
    .debounce(0.5, scheduler: MainScheduler.instance) // Wait 0.5 for changes.
    .distinctUntilChanged() // If they didn't occur, check if the new value is the same as old.
    .filter { !$0.isEmpty }

сообщение об ошибке:

"Невозможно преобразовать значение типа «Double» в ожидаемый тип аргумента «RxTimeInterval» (он же «DispatchTimeInterval») «

Ответы [ 2 ]

1 голос
/ 08 июня 2019
searchBar
    .rx.text // Observable property thanks to RxCocoa
    .orEmpty // Make it non-optional
    .debounce(.milliseconds(500), scheduler: MainScheduler.instance) // Wait 0.5 for changes.
    .distinctUntilChanged() // If they didn't occur, check if the new value is the same as old.
    .filter { !$0.isEmpty }
0 голосов
/ 08 июня 2019

Изменить эту строку:

.debounce(RxTimeInterval(0.5), scheduler: MainScheduler.instance)
...