Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow components to register themselves #58

Open
7 tasks
curran opened this issue Dec 5, 2015 · 1 comment
Open
7 tasks

Allow components to register themselves #58

curran opened this issue Dec 5, 2015 · 1 comment

Comments

@curran
Copy link
Collaborator

curran commented Dec 5, 2015

In the case that the browser global Chiasm is defined at the time a given module is loaded (included as a script tag), that module should be able to register itself as a plugin in the Chiasm runtime. For this, the plugins object for Chiasm could use prototypal inheritence, and inherit from a global set of plugins.

Examples would be much simpler (no Chiasm boilerplate with plugin assignment necessary). Only a single <script> tag would be necessary to include a Chiasm component on a page. It must be placed after the Chiasm runtime script, chiasm.js.

The following modules should have UMD builds that automatically register themselves:

  • chiasm-charts - should call registerPlugins to register all chart types
  • chiasm-dataset-loader - should call registerPlugin to register itself
  • chiasm-links
  • chiasm-layout
  • chiasm-injector
  • chiasm-crossfilter
  • chiasm-data-reduction
@curran
Copy link
Collaborator Author

curran commented Dec 6, 2015

The API could look something like this:

Chiasm.registerPlugin(pluginName, constructor);
Chiasm.registerPlugins(plugins);

var chiasm1 = Chiasm();
chiasm1.registerPlugin(pluginName, constructor);
chiasm1.registerPlugins(plugins);

var chiasm2 = Chiasm(chiasm1);
chiasm2.registerPlugin(pluginName, constructor);
chiasm2.registerPlugins(plugins);

This should use prototypal inheritence. This would enable nested Chiasm instances, as is required for small multiples #60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant