美文网首页
3. RxSwift 绑定 bind、bindTo、Binder

3. RxSwift 绑定 bind、bindTo、Binder

作者: xxxixxxx | 来源:发表于2020-11-16 09:24 被阅读0次

bind

let ob = Observable<Int>.interval(1, scheduler: MainScheduler.asyncInstance)

ob.map {
// 对值进一步处理然后返回
    "count " + "\($0)"
}
.bind { text in
    countLab.text = text
}.disposed(by: disposeBag)

ob.bind { x in
    print(x)
}.disposed(by: disposeBag)

Binder + bindTo

let ob = Observable<Int>.interval(1, scheduler: MainScheduler.asyncInstance)
let observer: Binder<String> = Binder(countLab) { lab, text in
    lab.text = text
}

ob.map {
    "c" + "\($0)"
}
.bind(to: observer)
.disposed(by: disposeBag)

相关文章

  • 3. RxSwift 绑定 bind、bindTo、Binder

    bind Binder + bindTo

  • RxSwift源码分析(6)——bind

    平常使用RxSwift时经常用到bind函数,意思是绑定,把监听和响应绑定在一起。它使我们的代码变得更加简洁,非常...

  • Activity与Service数据交互的几种方式

    扩展Binder 在绑定服务后,会回调onBind方法,此方法会返回IBinder。我们可以通过扩展自己的Bind...

  • PHP Closure类的bind()和bindTo()怎么用?

    看PHP手册关于Closure的bind和bindTo的用法。真心没看懂,不理解其中的概念。比如Closure::...

  • vue03

    v-bind动态绑定class(对象语法) v-bind动态绑定class(数组语法) v-bind动态绑定sty...

  • 头条面经

    1.document.getElementByClassName实现 2.bind函数实现 3.双向绑定实现 4....

  • jQuery(3)

    一 事件绑定 绑定 $().bind(事件类型,function(){}); $().bind(事件类型1,事件类...

  • React事件绑定

    1、在构造函数内使用bind绑定this 2、箭头函数绑定this 3、使用bind()绑定this 4、使用箭头...

  • 2018-09-16练习与复习

    v-bind绑定属性; v-bind:“属性名”v-bind:的简写(:)列 v-bind小项目 v-on:绑定事...

  • Vue.js 笔记

    v-bind:绑定属性 v-bind绑定属性,v-bind:属性名=‘值’,v-bind :属性名=‘值’ v-m...

网友评论

      本文标题:3. RxSwift 绑定 bind、bindTo、Binder

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