import { Observable, MonoTypeOperatorFunction } from 'rxjs'; import { HasEventTargetAddRemove } from 'rxjs/internal/observable/fromEvent'; import { QueryList } from '@angular/core'; /** * Delays the emission of each value from the source Observable by a time span determined by the `delay` function. * If the `notifier` Observable emits before the delay expires, the delayed emission is cancelled. * * This operator is useful for postponing the observable emissions until certain conditions are met, * represented by the passage of time defined by `delay`. It also allows for a way to preemptively * cancel the delay in response to another observable's emission. * * @template T The type of items emitted by the source Observable. * @param {() => number} delay A function that returns the delay (in milliseconds) before the source Observable's values are emitted. * @param {Observable} notifier An Observable that cancels the delay when it emits. * @returns {MonoTypeOperatorFunction} An Observable that emits the source Observable's items with a delay if not cancelled. * @example * ```ts * // Delay each number emission by 1 second, unless the 'cancel' button is clicked. * const delayedNumbers$ = of(1, 2, 3).pipe( * delayUntil(() => 1000, fromEvent(cancelButton, 'click')) * ); * * delayedNumbers$.subscribe(console.log); * ``` */ declare function delayUntil(delay: () => number, notifier: Observable): MonoTypeOperatorFunction; /** * Creates an RxJS Observable that emits mutation records for changes in a DOM element's attributes, * child list, and subtree. It uses the `MutationObserver` Web API to observe mutations on the specified * element according to the options provided. * * @param {Element} element The DOM element to observe for mutations. * @param {MutationObserverInit} options An object that specifies which DOM mutations should be reported. * Options include attributes, childList, subtree, attributeOldValue, characterData, characterDataOldValue, * and attributeFilter. * @returns {Observable} An Observable that emits a `MutationRecord` each time a mutation * matching the specified options occurs in the observed element. * @example * ```ts * // Observing changes to the child list of an element * const element = document.getElementById('my-element'); * const mutationOptions = { childList: true }; * * fromElementMutation$(element, mutationOptions).subscribe((mutation) => console.log('Mutation detected:', mutation)); * ``` * Note: Always remember to unsubscribe from the observable to prevent memory leaks. */ declare function fromElementMutation$(element: Element, options: MutationObserverInit): Observable; /** * Creates an RxJS Observable that emits an array of `ResizeObserverEntry` objects whenever * the target element's size changes. This function provides a reactive way to observe * and respond to changes in an element's dimensions, using the `ResizeObserver` Web API. * * The observable debounces the emitted values to improve performance and reduce the frequency * of change detection runs in Angular applications. The debounce time can be adjusted via * the `debounceDuration` parameter. * * @param {Element} element The DOM element to observe for size changes. * @param {number} [debounceDuration=50] The time, in milliseconds, to debounce the emitted * values. Defaults to 50ms. * @returns {Observable} An Observable that emits the resize events * for the observed element. Each emission is an array of `ResizeObserverEntry` objects, one * for each observed element that experienced a resize. * @example * ```ts * // Observing resize events of an element with a 100ms debounce duration * const element = document.getElementById('resizable-element'); * fromElementResize$(element, 100).subscribe((entries) => console.log('Element resized:', entries)); * ``` * * Always unsubscribe from the observable to clean up resources and prevent memory leaks. */ declare function fromElementResize$(element: Element, debounceDuration?: number): Observable; /** * Creates an Observable that emits events of a specific type from one or multiple event targets. * It listens to multiple event types on the given target(s) and emits the events through a single * Observable stream, simplifying the handling of related event types. * * @template T The event object type that the Observable will emit. * @param {HasEventTargetAddRemove | HasEventTargetAddRemove[]} target The DOM element(s) or event target(s) to listen on. * @param {...string[]} events The names of the events to listen for on the target(s). * @returns {Observable} An Observable that emits an event each time one of the specified events occurs on the given target(s). * * @example * ```ts * // Listen to both 'click' and 'keyup' events on document * fromEvents(document, 'click', 'keyup').subscribe(event => { * console.log('Event occurred:', event); * }); * * // Listen to 'mousemove' event on multiple elements * const elements = [document.getElementById('first'), document.getElementById('second')]; * fromEvents(elements, 'mousemove').subscribe(event => { * console.log('Mouse moved over:', event.target); * }); * ``` */ declare function fromEvents(target: HasEventTargetAddRemove | HasEventTargetAddRemove[], ...events: string[]): Observable; /** * Creates an Observable from an Angular QueryList. The Observable emits the initial state * of the QueryList and continues to emit updates every time the QueryList changes. * This utility function is useful for integrating Angular's QueryList changes into * the RxJS reactive data flow, allowing developers to apply RxJS operators and * subscriptions to respond to QueryList updates. * * @template T The type of elements contained within the QueryList. * @param {QueryList} queryList The QueryList instance to observe. * @returns {Observable>} An Observable that emits the current state of the QueryList * and updates whenever the QueryList changes. * @example * ```ts * // Assuming 'items' is a QueryList of component instances or DOM elements * fromQueryList(items).subscribe(queryList => { * console.log('QueryList changed:', queryList); * }); * ``` */ declare function fromQueryList(queryList: QueryList): Observable>; export { delayUntil, fromElementMutation$, fromElementResize$, fromEvents, fromQueryList };