mardi 7 novembre 2017

How to load plugin modules in Angular 4

I'm developing a dashboard in angular 4 which will allow other developers to create plugins for displaying various data. The dashboard has some common elements such a navigation bar that will show all available plugins. Here is where my problem comes. I would like the developers to register their plugins into the dashboard without having to modify the dashboard's source code. This brings two issues to me:

  1. How the dashboard can discover these plugins? Ideally, I would like to instantiate them as singletons at bootstrap time, and let them "announce" themselves using some form of plugin registry service. I actually created this service, but haven't been able to create the plugin instances. I've seen there are workaround's to dynamically load components from a source folder, but they all look as hacks and very fragile.

  2. How to register the plugin routing routes.

Any advice on which design pattern would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire