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

plugins documentation #1

Open
hdngr opened this issue Nov 12, 2014 · 0 comments
Open

plugins documentation #1

hdngr opened this issue Nov 12, 2014 · 0 comments

Comments

@hdngr
Copy link

hdngr commented Nov 12, 2014

including plugins

  1. Include the plugins code in your application:
    <script src="path/to/some/alchemyPlugin/somePlugin.js"></script>
  2. Initialize the plugin in your instance of alchemy by passing in the name of one or more plugins:
conf = {
    ...
    plugins: [ 'somePlugin', 'someOtherPlugin']
    ...
    }

writing your own plugin

Basics:

  1. Your plugin script should come AFTER the main alchemy.js script is loaded.
  2. Your plugin should extend the Alchemy prototype with a callable, for example:
Alchemy.prototype.plugins.somePlugin = function (alchemyInstance) {
   // something amazing happens and it handles all of the 
   // logic to get your plugin loaded and playing nicely with the core Alchemy app
}

OR

Alchemy::plugins.somePlugin = (alchemyInstance) ->
   # something amazing!

alchemyInstance contains access to the conf (alchemyInstance.conf) as well as the API methods for that instance (alchemyInstance.get.nodes(), etc.)

Additionally, for your application, you can extend the Alchemy default configurations. If you are using lodash like we do, something like Alchemy::defaults = _.merge({}, controlDashDefaults, Alchemy::defaults). If you do add confs, you may want to write a test that makes sure none of the Alchemy.defaults are getting overwritten. Rather, that you are extending the defaults, so that the user can overwrite specific defaults for your plugin directly.

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