I'm looking for a way to realize the following use-case:
- I have many modules and each one of them has a wire spec that exposes its components
- To assemble an application, I select the modules and use their wire-spec
- The wire-spec of the application is the merge of wire-specs of used modules: (3.1) I start by 'requiring' the wire-spec of each module as objects. (3.2) Then, I merge the objects. (3.3) And, finally, I return the result as the object defining the wire-spec of the application.
Here is a sample of an application context-spec:
define(["jquery", "module1-wire-spec", "module2-wire-spec"], function(jquery, module1WireSpec, module2WireSpec) {
return jquery.extend(true, module1WireSpec, module2WireSpec);
});
I have read several times wire documentation hoping to find a 'native' way to do the above but I failed so far to find one.
A 'native' way would be a factory like the 'wire' factory but instead of creating a child-context for each module, I'm looking to see the components of each module as direct components of the application context.
Spring, for instance, allows importing a context definition into another one and the result is as if the content of the imported context has been inlined with the importing context.
A new feature has been added to
cujojs/wire
to allow import of contexts.As of version
0.10.8
, the keywordimports
accepts:Check here for more details.