plugins/base.js

  1. const base = require("../base");
  2. const ripe = base.ripe;
  3. ripe.Ripe.plugins = ripe.Ripe.plugins || {};
  4. /**
  5. * @class
  6. * @augments Observable
  7. * @classdesc Base class of a Ripe Plugin.
  8. */
  9. ripe.Ripe.plugins.Plugin = function() {
  10. ripe.Observable.call(this);
  11. };
  12. ripe.Ripe.plugins.Plugin.prototype = ripe.build(ripe.Observable.prototype);
  13. ripe.Ripe.plugins.Plugin.prototype.constructor = ripe.Ripe.plugins.Plugin;
  14. /**
  15. * Registers this plugin to the provided Ripe instance.
  16. *
  17. * @param {Ripe} owner The Ripe instance to register to.
  18. */
  19. ripe.Ripe.plugins.Plugin.prototype.register = function(owner) {
  20. this.owner = owner;
  21. ripe.Observable.prototype.init.call(this);
  22. };
  23. /**
  24. * Unregisters this plugin from its owner.
  25. *
  26. * @param {Ripe} owner The Ripe instance to unregister from.
  27. */
  28. ripe.Ripe.plugins.Plugin.prototype.unregister = function(owner) {
  29. this.owner = null;
  30. ripe.Observable.prototype.deinit.call(this);
  31. };
  32. if (typeof module !== "undefined") {
  33. module.exports = {
  34. ripe: ripe
  35. };
  36. }