unique-selection-dispatcher.d-DSFqf1MM.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import * as i0 from '@angular/core';
  2. import { OnDestroy } from '@angular/core';
  3. type UniqueSelectionDispatcherListener = (id: string, name: string) => void;
  4. /**
  5. * Class to coordinate unique selection based on name.
  6. * Intended to be consumed as an Angular service.
  7. * This service is needed because native radio change events are only fired on the item currently
  8. * being selected, and we still need to uncheck the previous selection.
  9. *
  10. * This service does not *store* any IDs and names because they may change at any time, so it is
  11. * less error-prone if they are simply passed through when the events occur.
  12. */
  13. declare class UniqueSelectionDispatcher implements OnDestroy {
  14. private _listeners;
  15. /**
  16. * Notify other items that selection for the given name has been set.
  17. * @param id ID of the item.
  18. * @param name Name of the item.
  19. */
  20. notify(id: string, name: string): void;
  21. /**
  22. * Listen for future changes to item selection.
  23. * @return Function used to deregister listener
  24. */
  25. listen(listener: UniqueSelectionDispatcherListener): () => void;
  26. ngOnDestroy(): void;
  27. static ɵfac: i0.ɵɵFactoryDeclaration<UniqueSelectionDispatcher, never>;
  28. static ɵprov: i0.ɵɵInjectableDeclaration<UniqueSelectionDispatcher>;
  29. }
  30. export { UniqueSelectionDispatcher as U };
  31. export type { UniqueSelectionDispatcherListener as a };