Module Class
Modules are the primary interface to mimeo. On a module, you can define injectables. Each injectable definition will return the current module, allowing you to chain injectable definitions.
Injectables consist of three parts: A name, a list of dependencies and an executable. The dependencies are names of other injectables that will be passed to the executable.
There are two ways of defining an injectable. The first is an array notation where the last entry in the array is the executable. The other is an executable that has the special properties $name and $inject.
Here is an example of the array-style. Two factories A and B are defined, with B having a dependency on A:
mimeo.module('example', [])
.factory('A', [() => {}])
.factory('B', ['B', (b) => {}])
And here's how the same example would look like with the executable style:
function A() {}
A.$name = 'A';
A.$inject = [];
function B() {}
B.$name = 'B';
B.$inject = ['A'];
mimeo.module('example', [])
.factory(A)
.factory(B);
The executable-style makes it very easy to separate out your code from the mimeo bindings. In the example, function A and B can be used independent of mimeo. This is great of unit-testing your code, as you can import the executables into your test suite without having to worry about mimeo.
Constructor
Module
()
Methods
component
-
Injectable
Components are meant to produce some output, regardless of what rendering technique you use
Parameters:
-
Injectable
Array | Functiondefinition
Returns:
factory
-
Injectable
Use factories for anything that doesn't create output
Parameters:
-
Injectable
Array | Functiondefinition
Returns:
run
-
Injectable
Defines an injectable that will be run after modules are instantiated.
Parameters:
-
Injectable
Array | Functiondefinition
Returns:
value
-
name
-
value
Values are different from factories and components in that there's no executable. It's just a name and a value.
Parameters:
-
name
StringName of value
-
value
Value you want available for injection
Returns:
Example:
mimeo.module('example', [])
.value('name', 'value')