this.counter$ = store.select(fromExample.getCounterCounter);

this.counter$ = store.select(fromExample.getCounterCounter);

上述調用返回一個Observable:

傳入select方法的fromExample.getCounterCounter是一個createSelector返回的值:

執行select操作:


pathOrMapFn就是fromExample.getCounterCounter指向的值:
注意,Store是Observable的子類,這個select是Store的重新實現:



這個source$就是store.select(fromExample.getCounterCounter);裏的store:

最後返回的是一個施加了MapOperator的新Store(新Observable):

而我們應用程序傳入selector的fromExample.getCounterCounter,體現在這個新store的什麼地方?

source就是我們應用代碼裏構造函數注入的store,父類是Observable.

對於source store,執行map裏指定的箭頭函數,即我們應用程序傳入store.select裏的函數:

位於第976行:


我們傳入的getCounter(第1061行的projector)被一個memoize函數修飾:

更多Jerry的原創文章,盡在:「汪子熙」: