API Docs for: 0.1.4
Show:

Module Class

Defined in: src/Module.js:5
Module: Mimeo

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

()

Defined in src/Module.js:5

Item Index

Methods

component

(
  • Injectable
)
Module chainable

Defined in src/Module.js:159

Components are meant to produce some output, regardless of what rendering technique you use

Parameters:

  • Injectable Array | Function

    definition

Returns:

factory

(
  • Injectable
)
Module chainable

Defined in src/Module.js:148

Use factories for anything that doesn't create output

Parameters:

  • Injectable Array | Function

    definition

Returns:

run

(
  • Injectable
)
Module chainable

Defined in src/Module.js:114

Defines an injectable that will be run after modules are instantiated.

Parameters:

  • Injectable Array | Function

    definition

Returns:

value

(
  • name
  • value
)
Module chainable

Defined in src/Module.js:171

Values are different from factories and components in that there's no executable. It's just a name and a value.

Parameters:

  • name String

    Name of value

  • value

    Value you want available for injection

Returns:

Example:

 mimeo.module('example', [])
     .value('name', 'value')