美文网首页
this.counter$ = store.select(fro

this.counter$ = store.select(fro

作者: _扫地僧_ | 来源:发表于2021-02-09 11:13 被阅读0次

    这个类型为Store<fromExample.State>的变量:

    本质是个Observable:

    store的source字段的_value里,包含了两个state的初始值:

    this.counter$ = store.select(fromExample.getCounterCounter)之后马上subscribe

    先执行this.counter$这个Observable自带的operator:

    这个DistinctUntilChangedOperator来自:




    map操作符执行的逻辑就是:

    source => pathOrMapFn(source ... )

    projectFn.apply最终会调用应用程序传入store.select里的函数:


    我们自己实现的getter在这里被调用:

    调用到应用程序自己的projector了:


    // 2020-11-05 3:36PM - 经过调试,最后发现,一旦对this.counter$调用
    // subscribe,最终会触发fromExample.getCounterCounter, 后者
    // 从当前最新的state里取数据
    

    更多Jerry的原创文章,尽在:"汪子熙":


    相关文章

      网友评论

          本文标题:this.counter$ = store.select(fro

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