Lazybox
Dependency injection container based on Map()
Usage
var Lazybox = ; var c = ; // Set parameterc; // Define a servicec; // Define a service with dependenciesc;c; c; // Logs 'Lazily initialized' // Define a generator service c;let id = c; // 0; // 1; // 2 ...
Dependency Injection
Providers
// Register a provider functionc; // Register a provider objectc;
API
container.match(pattern, callback)
Use path-to-regexp to match keys.
This does not initialize any service by calling get()
Arguments
- pattern: A key pattern
- callback: A function
(key, params, container)
to call for each result.
cnt;
container.setdefault(key, value)
Similar to Python's dict.setdefault(key, value)
method.
It gets the value of a key or sets it to value if not defined.