observers-b198f831.js 765 B

12345678910111213141516171819202122232425
  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. /**
  7. * This utility ensures observers are created only for browser contexts.
  8. *
  9. * @param type - the type of observer to create
  10. * @param callback - the observer callback
  11. * @param options - the observer options
  12. */
  13. function createObserver(type, callback, options) {
  14. const Observer = getObserver(type);
  15. return new Observer(callback, options) ;
  16. }
  17. function getObserver(type) {
  18. return (type === "intersection"
  19. ? window.IntersectionObserver
  20. : type === "mutation"
  21. ? window.MutationObserver
  22. : window.ResizeObserver);
  23. }
  24. export { createObserver as c };