md2
Version:
Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Chips(Tags), Collapse, Colorpicker, Data Table, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.
51 lines • 2.48 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Injectable, Optional, SkipSelf } from '@angular/core';
/**
* Class to coordinate unique selection based on name.
* Intended to be consumed as an Angular service.
* This service is needed because native radio change events are only fired on the item currently
* being selected, and we still need to uncheck the previous selection.
*
* This service does not *store* any IDs and names because they may change at any time, so it is
* less error-prone if they are simply passed through when the events occur.
*/
var UniqueSelectionDispatcher = (function () {
function UniqueSelectionDispatcher() {
this._listeners = [];
}
/**
* Notify other items that selection for the given name has been set.
* @param id ID of the item.
* @param name Name of the item.
*/
UniqueSelectionDispatcher.prototype.notify = function (id, name) {
for (var _i = 0, _a = this._listeners; _i < _a.length; _i++) {
var listener = _a[_i];
listener(id, name);
}
};
/** Listen for future changes to item selection. */
UniqueSelectionDispatcher.prototype.listen = function (listener) {
this._listeners.push(listener);
};
return UniqueSelectionDispatcher;
}());
UniqueSelectionDispatcher = __decorate([
Injectable()
], UniqueSelectionDispatcher);
export { UniqueSelectionDispatcher };
export function UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY(parentDispatcher) {
return parentDispatcher || new UniqueSelectionDispatcher();
}
export var UNIQUE_SELECTION_DISPATCHER_PROVIDER = {
// If there is already a dispatcher available, use that. Otherwise, provide a new one.
provide: UniqueSelectionDispatcher,
deps: [[new Optional(), new SkipSelf(), UniqueSelectionDispatcher]],
useFactory: UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY
};
//# sourceMappingURL=unique-selection-dispatcher.js.map