layer/layerRec/root.js

  1. 'use strict';
  2. /**
  3. * @class Root
  4. */
  5. class Root {
  6. // the thing every thing else inherits from.
  7. // thing in here should be applicable to both layer-ish classes (including FCs),
  8. // and legend-ish classes.
  9. constructor () {
  10. // TODO maybe pass in config, store it?
  11. this._name = '';
  12. this._visibleListeners = [];
  13. }
  14. // everyone needs a name
  15. get name () { return this._name; }
  16. set name (value) { this._name = value; }
  17. get symbology () { return this._symbology; }
  18. set symbology (value) { this._symbology = value; }
  19. get extent () { return this._extent; }
  20. set extent (value) { this._extent = value; }
  21. /**
  22. * Utility for triggering an event and giving it to the listeners
  23. */
  24. _fireEvent (handlerArray, ...eventParams) {
  25. // if we don't copy the array we could be looping on an array
  26. // that is being modified as it is being read
  27. handlerArray.slice(0).forEach(l => l(...eventParams));
  28. }
  29. }
  30. module.exports = () => ({
  31. Root
  32. });