Skip to content

Plugin dependencies

marcelklehr edited this page Aug 2, 2012 · 2 revisions

As your plugins become more and more complex, you will find yourself in the need to manage dependencies between plugins. E.g. you want the hooks of a certain plugin to be executed before yours. You can manage these dependencies in your plugin definition file ep.json:

{
  "parts": [
    {
      "name": "plugin",
      "pre": [],
      "post": ["ep_onemoreplugin/partone"]
      "hooks": {
        "toolbarButtons": "ep_monospace/plugin:getSomeToolbarButtons",
        "changeToMonospace": "ep_monospace/plugin:getSomePopups",
      }
    },
    {
      "name": "otherpart",
      "pre": ["ep_my_example/somepart", "ep_otherplugin/main"],
      "post": [],
      "hooks": {
        "somehookname": "ep_my_example/otherpart:somehook",
        "morehook": "ep_my_example/otherpart:morehook"
      }
    }
  ]
}

parts

Usually a plugin will add only one functionality at a time, so it will probably only use one part definition to register its hooks. However, sometimes you have to put different (unrelated) functionalities into one plugin. For this you will want use parts, so other plugins can depend on them.

pre/post

The "pre" and "post" definitions, affect the order in which parts of a plugin are executed. This ensures that plugins and their hooks are executed in the correct order.

"pre" lists parts that must be executed before the defining part. "post" lists parts that must be executed after the defining part.

You can, on a basic level, think of this as double-ended dependency listing. If you have a dependency on another plugin, you can make sure it loads before yours by putting it in "pre". If you are setting up things that might need to be used by a plugin later, you can ensure proper order by putting it in "post".

Note that it would be far more sane to use "pre" in almost any case, but if you want to change config variables for another plugin, or maybe modify its environment, "post" could definitely be useful.

Also, note that dependencies should also be listed in your package.json, so they can be npm install'd automagically when your plugin gets installed.

General

Resources

For Developers

How to's

Set up

Advanced steps

Integrating Etherpad in your web app

for Developers

Clone this wiki locally