Skip to content

Instantly share code, notes, and snippets.

@juandopazo
Created July 31, 2012 17:19
Show Gist options
  • Save juandopazo/3218679 to your computer and use it in GitHub Desktop.
Save juandopazo/3218679 to your computer and use it in GitHub Desktop.
PluginObserver
function PluginObserver() {
this.publish('plug', {
emitFacade: true,
defaultFn: '_plug'
});
this.publish('unplug', {
emitFacade: true,
defaultFn: '_unplug'
});
}
PluginObserver.prototype.plug = function (plugin, config) {
this.fire('plug', { plugin: plugin, config: config });
return this;
};
PluginObserver.prototype._plug = function (e) {
Y.Widget.prototype.plug.call(this, e.plugin, e.config);
};
PluginObserver.prototype.unplug = function (plugin) {
this.fire('unplug', { plugin: plugin });
return this;
};
PluginObserver.prototype._unplug = function (e) {
Y.Widget.prototype.unplug.call(this, e.plugin);
};
Y.MyWidget = Y.Base.create('myWidget', Y.Widget, [PluginObserver]);
@juandopazo
Copy link
Author

I don't know if it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment