SAP Spartacus ProductConnector和ProductService实现
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus ProductConnector和ProductService实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
名稱:ProductConnector
路徑:在core文件夾下
通過ProductAdapter向Commerce Cloud發起數據請求:
邏輯很簡單,直接調用adapter的load方法。
什么時候ProductConnector會被調用?
let ProductEffects = class ProductEffects {constructor(actions$, productConnector) {this.actions$ = actions$;this.productConnector = productConnector;// we want to cancel all ongoing requests when currency or language changes,this.contextChange$ = this.actions$.pipe(ofType(CURRENCY_CHANGE, LANGUAGE_CHANGE));this.loadProduct$ = createEffect(() => ({ scheduler, debounce = 0 } = {}) => this.actions$.pipe(ofType(LOAD_PRODUCT), map((action) => ({code: action.payload,scope: action.meta.scope,})), // we are grouping all load actions that happens at the same time// to optimize loading and pass them all to productConnector.getManybufferDebounceTime(debounce, scheduler), mergeMap((products) => merge(...this.productConnector.getMany(products).map(this.productLoadEffect))), withdrawOn(this.contextChange$)));}有17個product需要加載:
loadProduct$的實現,包含了加載多個product的邏輯:
這17個product是外層傳進來的:
看這個getProductForScope是何時被調用的:
又出現了一個ProductService:
位于facade層:
Spartacus-storefront.js:
這個ProductCarouselComponent位于storefrontlib文件夾內:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的SAP Spartacus ProductConnector和ProductService实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: flash如何制作通过点击按钮改变图片大
- 下一篇: 【软件使用】VSCode 注释与取消注释