Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic component loading from external content

The system I am working on consists of a number of distributed microservices with potentially multiple versions of each component active at the same time.

The Angular2 app I am attempting to build shall be able to interact with each of these components by means of websockets. Because it seems unfeasible to prepare this application for all future versions and features of each component, the respective protocol implementation and even new components, I would like to push this responsibility to the components itself.

Each component is able to communicate its capabilities (in the form of a NG2 component) as well as the protocol implementation and the necessary GUI elements (HTML/CSS) via a package sent over the very same websocket connection.

Is there a pattern that enables this kind of 'on-demand-loading' of components and their templates in ng2?

like image 785
Jens Habegger Avatar asked Oct 18 '22 11:10

Jens Habegger


1 Answers

It looks like you can try to use router lazy loading and provide custom implementation of NgModuleFactoryLoader which can load components via websocket.

like image 159
kemsky Avatar answered Oct 30 '22 21:10

kemsky