UNPKG

@funnelenvy-npm/fe-dev-utils

Version:

Helper function to build client side A/B tests

22 lines (21 loc) 1 kB
/** * Observer function that checks for a target selector * @param {Object} options - Options object to configure the function. * @param {String} options.selector - CSS selector to wait for. * @param {function} options.callback - A callback function to run when selector is available. * @param {Object} [options.config] - (Optional) observer function options to expand or override default config. * @param {String} [options.activity] - (Optional) name of activity error occurred in. * @param {function} [options.errorHandler] - (Optional) The error handler. */ type ObserveDomOptions = { selector: string; callback: (mutation: MutationRecord) => void; config?: MutationObserverInit; activity?: string | null; errorHandler?: ((params: { activity: string | null; error: Error; }) => void) | null; }; declare const observeDom: ({ selector, callback, config, activity, errorHandler, }: ObserveDomOptions) => (() => void) | null; export default observeDom;