Core/PluginManager

Plugin manager.

Example:

const PluginManager = require('./plugin-manager');

PluginManager.register('fast-click-highlight', ['view', 'field'], {
    color : "red",
    events: {
        'click .fast-click-highlighted': 'onClickItem'
    },
    onClickItem: function(e) {
        alert(1)
    },

    // The onAttach function will be called every time the plugin is
    // attached to a new component. It will be executed from the scope of
    // the component being attached to.
    //Applied after the plugin has been mixed into the component.
    onAttach: function(component, plugin) {
        this.on('render', function(){
            //same as plugin.color and component.$el.css
            this.$el.css('color', this.color);
        });
    }
});

If you want to use the current plugin for a view, you have to declare the plugin in it:

const ViewManager = require('../view/view-manager');
var MyView = ViewManager.View.extend({
    initialize: function(options) {},
    plugins: ['fast-click-highlight'],
     ...,
});

// or

$plugins: [{
    'fast-click-highlight': {
        events: {
            'click article' : 'onClickItem'
        }
    }
}],

onClickItem: function() {
    alert(2);
}

If you want to disable a plugin, you have to use the disabledPlugins property as in the following example:

var MyView = ViewManager.View.extend({
    initialize: function(options) {},
    disabledPlugins: ['fast-click-highlight'],
    ...,
});