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. }
  13. // everyone needs a name
  14. get name () { return this._name; }
  15. set name (value) { this._name = value; }
  16. get symbology () { return this._symbology; }
  17. set symbology (value) { this._symbology = value; }
  18. get extent () { return this._extent; }
  19. set extent (value) { this._extent = value; }
  20. /**
  21. * Utility for triggering an event and giving it to the listeners
  22. *
  23. * @function _fireEvent
  24. * @private
  25. * @param {Array} handlerArray array of event handler functions
  26. * @param {...Object} eventParams arbitrary set of parameters to pass to the event handler functions
  27. */
  28. _fireEvent (handlerArray, ...eventParams) {
  29. // if we don't copy the array we could be looping on an array
  30. // that is being modified as it is being read
  31. handlerArray.slice(0).forEach(l => l(...eventParams));
  32. }
  33. }
  34. module.exports = () => ({
  35. Root
  36. });