UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

27 lines (24 loc) 832 B
/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. */ import { Build } from '@stencil/core/internal/client'; /** * This utility ensures observers are created only for browser contexts. * * @param type - the type of observer to create * @param callback - the observer callback * @param options - the observer options */ function createObserver(type, callback, options) { const Observer = getObserver(type); return Build.isBrowser ? new Observer(callback, options) : undefined; } function getObserver(type) { return (type === "intersection" ? window.IntersectionObserver : type === "mutation" ? window.MutationObserver : window.ResizeObserver); } export { createObserver as c };