[Selection] Allow providers to return array

...to allow one-to-many providers for actions, as is useful
for Create et al (and, in this specific case, to support
adapters.)
This commit is contained in:
Victor Woeltjen 2016-09-23 15:45:46 -07:00
parent 9e19296b14
commit 8dfa8df28a

View File

@ -6,10 +6,14 @@ define([], function () {
ActionRegistry.prototype.get = function (context) {
return this.providers.filter(function (provider) {
return provider.appliesTo(context);
});
}).map(function (provider) {
return provider.get(context);
}).reduce(function (a, b) {
return Array.isArray(b) ? a.concat(b) : a.concat([b]);
}, []);
};
ActionRegistry.prototype.addProvider = function (provider) {
ActionRegistry.prototype.register = function (provider) {
this.providers.push(provider);
};