MultiGreet demonstrates how to use the js-plugins NPM package.
The purpose of MultiGreet is to print a greeting to a set of audience members. However the list of audience members is not pre-defined, or even a program input: it is determined by connecting MultiGreet plugins.
Each plugin implements an interface that returns the name of an audience member. At runtime,
MultiGreet scans for plugins that extend the multigreet:audience extension point and then
greets the aggregated audience by name.
Plugins are implemented in the three main ways:
- Direct registration with the plugin manager in the host app (i.e. MultiGreet)
- Packages in other directories (sibling and non-sibling)
- Packages installed globally
MultiGreet registers all of these audiences, and then on connecting processes their return values.
- From the MultiGreet repository, run
npm install -gto install globally. - Run
multigreetto see who is in the audience. - Install the
plugin-planetspackage globally by runningnpm run installGlobal. - Run
multigreetagain to see who is in the new audience. - If you like, run
npm uninstall -g js-plugins-example-planetsand try again.