unique-selection-dispatcher.d.ts 1.3 KB

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