rxswift 防止按钮多次点击

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)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,145评论 1 32
  • 2017.02.22 可以练习,每当这个时候,脑袋就犯困,我这脑袋真是神奇呀,一说让你做事情,你就犯困,你可不要太...
    Carden阅读 1,378评论 0 1
  • 1.badgeVaule气泡提示 2.git终端命令方法> pwd查看全部 >cd>ls >之后桌面找到文件夹内容...
    i得深刻方得S阅读 4,770评论 1 9
  • 午后在看米兰.昆德拉的《不能承受的生命之轻》,本书讲爱情的。托马斯和特蕾莎之间的爱情。托马斯有很多情人,...
    清梦0109阅读 205评论 0 1
  • Less clear, however, is whether or notassortative mating ...
    敢敢宝宝阅读 254评论 0 1