美文网首页SAP
SAP 电商云 Spartacus UI ComponentDa

SAP 电商云 Spartacus UI ComponentDa

作者: 华山令狐冲 | 来源:发表于2021-12-17 08:28 被阅读0次

为什么 this.componentService.getItems 最后就触发到

Component-data.provider.ts 工厂函数的执行了?


29行的 getService:


getService 的实现在第 70 行,又会调用到第 79 行的 getContext:

这里的 componentData,就和之前这篇文章如何在 SAP 电商云 Spartacus UI 里访问 CMS Component data 数据介绍的内容串联起来了。

输入参数:


首先明确,为什么 defer 里的工厂函数会被执行?一定是因为 defer 返回的 Observable 在某处被 subscribe 了。

getItems -> getService -> getContext -> this.componentData.data$

因为 getItems 被 async pipe 执行,所以 this.componentData.data$ 被 subscribe.

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


相关文章

网友评论

    本文标题:SAP 电商云 Spartacus UI ComponentDa

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