美文网首页tips
rxswift 防止按钮多次点击

rxswift 防止按钮多次点击

作者: crazyfox | 来源:发表于2019-08-28 16:26 被阅读0次
self.button.rx.tap.asObservable().debounce(1, scheduler: MainScheduler.instance).subscribe(onNext: { [weak self] in
//Logic
})

debounce

过滤掉高频产生的元素

tableView cell点击事件也可以

        self.tableView.rx.itemSelected.asObservable().debounce(1, scheduler: MainScheduler.instance)
            .map{ indexPath in
            return (indexPath,self.dataSources![indexPath])
        }
        .subscribe(onNext: { [weak self] indexPath,model in
            if let strongself = self{
                strongself.selectCell(indexPath, model: model)
            }
        })
        .disposed(by: self.disposeBag)

相关文章

网友评论

    本文标题:rxswift 防止按钮多次点击

    本文链接:https://www.haomeiwen.com/subject/mxrmectx.html