observers-d9fdf006.js 789 B

123456789101112131415161718192021222324252627
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. 'use strict';
  7. /**
  8. * This utility ensures observers are created only for browser contexts.
  9. *
  10. * @param type - the type of observer to create
  11. * @param callback - the observer callback
  12. * @param options - the observer options
  13. */
  14. function createObserver(type, callback, options) {
  15. const Observer = getObserver(type);
  16. return new Observer(callback, options) ;
  17. }
  18. function getObserver(type) {
  19. return (type === "intersection"
  20. ? window.IntersectionObserver
  21. : type === "mutation"
  22. ? window.MutationObserver
  23. : window.ResizeObserver);
  24. }
  25. exports.createObserver = createObserver;