头图

This entry is located in the rxjs from Operator call on line 218 in the figure below:

Here we pass a function to from:

The specific functions passed in are as follows:

This function returns a promise, which is used as the input type of the from operator. This function is maintained in the module field of the featureConfig json object:

This json object is injected into the configuration object config through provideConfig in the Spartacus code, and the field name is featureModules:

Will chunk loading be triggered here?

It can be confirmed from the figure below that the import command on line 19 in the figure above will trigger the loading of spartacus/cart/quick/order chunk:

After the import statement on line 19 is executed, use then to return the loaded QuickOrderModule definition, which reflects the semantics of Promise.

So when the code executes to switchMap on line 220 in the figure below, the passed in module is the loaded QuickOrderModule class:

EventService is also used here to throw an event of successful loading of the delayed loading chunk: ModuleInitializedEvent

More original articles by Jerry, all in: "Wang Zixi":


注销
1k 声望1.6k 粉丝

invalid