这个类型为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的原创文章,尽在:"汪子熙":
网友评论