c9/architect — pull request #23 by janjongboom (2013-09-03 16:33:22+00:00)
Title: Allow architect plugins to be unloaded and loaded at runtime

At the moment an architect application is 'set'. It gets created and then it cannot be modified. However, there might be cases where you'd want to load extra plugins, or unload others while running an application without destroying it. By exposing `registerPlugin` on the app prototype this gets enabled. The code to use this:

```javascript
// create normal architect app
var architect = require("architect-git");
var config = architect.loadConfig(__dirname + "/config.js");
architect.createApp(config, function (err, app) {
// some extra plugins to be loaded
var plugins = [{packagePath: './some-extra-plugin'}];
architect.resolveConfig(plugins, __dirname, function(err, resolved) {
if (err) {
return console.error('Resolve config failed', resolved);
}
app.loadPlugins(resolved, function() {
return console.log('Registered plugins', app.config);
});
});
});
```

Or to unload an existing plugin:

```
var plugin = app.config.filter(function(c) {
return c.packagePath === 'something' && c.bla === 'zus';
})[0];
plugin.destroy()
```

The plugin can implement `onDestroy()` to unregister express handlers or whatever.