UNPKG

@angular2-material/core

Version:
1 lines 1.86 kB
{"version":3,"sources":["core/coordination/unique-selection-dispatcher.ts"],"names":[],"mappings":";;;;;;;;;OAAO,EAAC,UAAU,EAAC,MAAM,eAAe;AAMxC;;;;;;;;GAQG;AAEH;IAAA;QACU,eAAU,GAA0C,EAAE,CAAC;IAajE,CAAC;IAXC,yEAAyE;IACzE,4CAAM,GAAN,UAAO,EAAU,EAAE,IAAY;QAC7B,GAAG,CAAC,CAAiB,UAAe,EAAf,KAAA,IAAI,CAAC,UAAU,EAAf,cAAe,EAAf,IAAe,CAAC;YAAhC,IAAI,QAAQ,SAAA;YACf,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SACpB;IACH,CAAC;IAED,mDAAmD;IACnD,4CAAM,GAAN,UAAO,QAA6C;QAClD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAdH;QAAC,UAAU,EAAE;;mCAAA;IAeb,kCAAC;AAAD,CAdA,AAcC,IAAA","file":"core/coordination/unique-selection-dispatcher.js","sourcesContent":["import {Injectable} from '@angular/core';\n\n\n// Users of the Dispatcher never need to see this type, but TypeScript requires it to be exported.\nexport type MdUniqueSelectionDispatcherListener = (id: string, name: string) => void;\n\n/**\n * Class to coordinate unique selection based on name.\n * Intended to be consumed as an Angular service.\n * This service is needed because native radio change events are only fired on the item currently\n * being selected, and we still need to uncheck the previous selection.\n *\n * This service does not *store* any IDs and names because they may change at any time, so it is\n * less error-prone if they are simply passed through when the events occur.\n */\n@Injectable()\nexport class MdUniqueSelectionDispatcher {\n private _listeners: MdUniqueSelectionDispatcherListener[] = [];\n\n /** Notify other items that selection for the given name has been set. */\n notify(id: string, name: string) {\n for (let listener of this._listeners) {\n listener(id, name);\n }\n }\n\n /** Listen for future changes to item selection. */\n listen(listener: MdUniqueSelectionDispatcherListener) {\n this._listeners.push(listener);\n }\n}\n"],"sourceRoot":"/source/"}