diff options
author | Christian <git-developer@users.noreply.github.com> | 2020-11-25 05:57:53 +0100 |
---|---|---|
committer | Christian <git-developer@users.noreply.github.com> | 2020-11-25 05:57:53 +0100 |
commit | d848e24e68ece83ea82d24f281a627025c40f77d (patch) | |
tree | 14ce9b9949a62f05c7c466848d333d6a8c6cb415 | |
parent | 36dd0d86226286ffbfc1e394b553fd59705c15ed (diff) |
feat(BCR2000): generalize container creation
-rw-r--r-- | res/controllers/midi-components-extension.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/res/controllers/midi-components-extension.js b/res/controllers/midi-components-extension.js index 780431491f..49c3dba8cb 100644 --- a/res/controllers/midi-components-extension.js +++ b/res/controllers/midi-components-extension.js @@ -745,7 +745,11 @@ * +- containers: an array of component container definitions (may be empty or omitted) * +- componentContainer * +- components: an object of component definitions for the component container. - * +- component: a component definition in the same format as described for decks + * | +- component: a component definition in the same format as described for decks + * +- type: (function, optional) constructor (default : `components.ComponentContainer`) + * +- options: (object, optional) constructor argument + * +- init: (function, optional) a function that is called after component creation and + * before first use * * @constructor * @extends {components.ComponentContainer} @@ -925,10 +929,14 @@ * @private */ createComponentContainer: function(containerDefinition) { - var container = new components.ComponentContainer(); + var containerType = containerDefinition.type || components.ComponentContainer; + var container = new containerType(containerDefinition.options); containerDefinition.components.forEach(function(componentDefinition, index) { container[index] = new componentDefinition.type(componentDefinition.options); }, this); + if (typeof containerDefinition.init === "function") { + containerDefinition.init.call(container); + } return container; }, |