- Source:
Methods
-
getValue(key)
-
Retrieve a stored value
The benefit of using this, instead of directly requiring a global file, is that you remove the hard link between them. Stored values are configured in a single place, so dependencies can be swapped out easily. Also, when requiring global modules, you have no control over the 'construction' time.
Parameters:
Name Type Description keystring Use a key from
app/data/Injectables.js- Source:
Returns:
The stored value
- Type
- any
-
setValue(key, value)
-
Save a value under a key for later use.
This is used as a way to store and access global dependencies, without hard references to specific files at the place they are used. This gives the option to swap out the dependencies with other in a single place, without affecting other code. It's a very basic form of Dependency Injection.
Currently the values are set in the
app/util/setupInjects.jsfunction that is called when bootstrapping the app.Parameters:
Name Type Description keystring Use a key from
app/data/Injectables.jsvalueany The value to store
- Source: