index.d.ts 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { AfterContentInit } from '@angular/core';
  2. import { BooleanInput } from '@angular/cdk/coercion';
  3. import { ElementRef } from '@angular/core';
  4. import { EventEmitter } from '@angular/core';
  5. import * as i0 from '@angular/core';
  6. import { NgZone } from '@angular/core';
  7. import { NumberInput } from '@angular/cdk/coercion';
  8. import { Observable } from 'rxjs';
  9. import { OnDestroy } from '@angular/core';
  10. /**
  11. * Directive that triggers a callback whenever the content of
  12. * its associated element has changed.
  13. */
  14. export declare class CdkObserveContent implements AfterContentInit, OnDestroy {
  15. private _contentObserver;
  16. private _elementRef;
  17. private _ngZone;
  18. /** Event emitted for each change in the element's content. */
  19. readonly event: EventEmitter<MutationRecord[]>;
  20. /**
  21. * Whether observing content is disabled. This option can be used
  22. * to disconnect the underlying MutationObserver until it is needed.
  23. */
  24. get disabled(): boolean;
  25. set disabled(value: BooleanInput);
  26. private _disabled;
  27. /** Debounce interval for emitting the changes. */
  28. get debounce(): number;
  29. set debounce(value: NumberInput);
  30. private _debounce;
  31. private _currentSubscription;
  32. constructor(_contentObserver: ContentObserver, _elementRef: ElementRef<HTMLElement>, _ngZone: NgZone);
  33. ngAfterContentInit(): void;
  34. ngOnDestroy(): void;
  35. private _subscribe;
  36. private _unsubscribe;
  37. static ɵfac: i0.ɵɵFactoryDeclaration<CdkObserveContent, never>;
  38. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkObserveContent, "[cdkObserveContent]", ["cdkObserveContent"], { "disabled": { "alias": "cdkObserveContentDisabled"; "required": false; }; "debounce": { "alias": "debounce"; "required": false; }; }, { "event": "cdkObserveContent"; }, never, never, false, never>;
  39. }
  40. /** An injectable service that allows watching elements for changes to their content. */
  41. export declare class ContentObserver implements OnDestroy {
  42. private _mutationObserverFactory;
  43. /** Keeps track of the existing MutationObservers so they can be reused. */
  44. private _observedElements;
  45. constructor(_mutationObserverFactory: MutationObserverFactory);
  46. ngOnDestroy(): void;
  47. /**
  48. * Observe content changes on an element.
  49. * @param element The element to observe for content changes.
  50. */
  51. observe(element: Element): Observable<MutationRecord[]>;
  52. /**
  53. * Observe content changes on an element.
  54. * @param element The element to observe for content changes.
  55. */
  56. observe(element: ElementRef<Element>): Observable<MutationRecord[]>;
  57. /**
  58. * Observes the given element by using the existing MutationObserver if available, or creating a
  59. * new one if not.
  60. */
  61. private _observeElement;
  62. /**
  63. * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is
  64. * observing this element.
  65. */
  66. private _unobserveElement;
  67. /** Clean up the underlying MutationObserver for the specified element. */
  68. private _cleanupObserver;
  69. static ɵfac: i0.ɵɵFactoryDeclaration<ContentObserver, never>;
  70. static ɵprov: i0.ɵɵInjectableDeclaration<ContentObserver>;
  71. }
  72. /**
  73. * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.
  74. * @docs-private
  75. */
  76. export declare class MutationObserverFactory {
  77. create(callback: MutationCallback): MutationObserver | null;
  78. static ɵfac: i0.ɵɵFactoryDeclaration<MutationObserverFactory, never>;
  79. static ɵprov: i0.ɵɵInjectableDeclaration<MutationObserverFactory>;
  80. }
  81. export declare class ObserversModule {
  82. static ɵfac: i0.ɵɵFactoryDeclaration<ObserversModule, never>;
  83. static ɵmod: i0.ɵɵNgModuleDeclaration<ObserversModule, [typeof CdkObserveContent], never, [typeof CdkObserveContent]>;
  84. static ɵinj: i0.ɵɵInjectorDeclaration<ObserversModule>;
  85. }
  86. export { }