MCPcopy
hub / github.com/flightjs/flight / defineComponent

Function defineComponent

lib/component.js:80–119  ·  view source on GitHub ↗
(/*mixins*/)

Source from the content-addressed store, hash-verified

78 // takes an unlimited number of mixin functions as arguments
79 // typical api call with 3 mixins: defineComponent(timeline, withTweetCapability, withScrollCapability);
80 function defineComponent(/*mixins*/) {
81 // unpacking arguments by hand benchmarked faster
82 var l = arguments.length;
83 var mixins = new Array(l);
84 for (var i = 0; i < l; i++) {
85 mixins[i] = arguments[i];
86 }
87
88 var Component = function() {};
89
90 Component.toString = Component.prototype.toString = prettyPrintMixins;
91 if (debug.enabled) {
92 Component.describe = Component.prototype.describe = Component.toString();
93 }
94
95 // 'options' is optional hash to be merged with 'defaults' in the component definition
96 Component.attachTo = attachTo;
97 // enables extension of existing "base" Components
98 Component.mixin = function() {
99 var newComponent = defineComponent(); //TODO: fix pretty print
100 var newPrototype = Object.create(Component.prototype);
101 newPrototype.mixedIn = [].concat(Component.prototype.mixedIn);
102 newPrototype.defaults = utils.merge(Component.prototype.defaults);
103 newPrototype.attrDef = Component.prototype.attrDef;
104 compose.mixin(newPrototype, arguments);
105 newComponent.prototype = newPrototype;
106 newComponent.prototype.constructor = newComponent;
107 return newComponent;
108 };
109 Component.teardownAll = teardownAll;
110
111 // prepend common mixins to supplied list, then mixin all flavors
112 if (debug.enabled) {
113 mixins.unshift(withLogging);
114 }
115 mixins.unshift(withBase, advice.withAdvice, registry.withRegistration);
116 compose.mixin(Component.prototype, mixins);
117
118 return Component;
119 }
120
121 defineComponent.teardownAll = function() {
122 registry.components.slice().forEach(function(c) {

Callers 10

registry_spec.jsFile · 0.85
utils_spec.jsFile · 0.85
mixItInFunction · 0.85
attribute_spec.jsFile · 0.85
instance_spec.jsFile · 0.85
advice_spec.jsFile · 0.85
logger_spec.jsFile · 0.85
fn_spec.jsFile · 0.85
events_spec.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected