Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mucsi96/di.js
Nano dependency injection framework for Javascript
https://github.com/mucsi96/di.js
Last synced: 5 days ago
JSON representation
Nano dependency injection framework for Javascript
- Host: GitHub
- URL: https://github.com/mucsi96/di.js
- Owner: mucsi96
- Created: 2014-02-26T09:05:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-03-26T14:19:02.000Z (over 10 years ago)
- Last Synced: 2024-10-12T03:13:07.448Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 273 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
register(moduleName, moduleConstructor, dependencies)
-----------------------------------------------------
Register a new module using its constructor**Parameters**
**moduleName**: *string*, modules name
**moduleConstructor**: *function*, modules constructor
**dependencies**: *string[]*, dependent module names
get(moduleName, forceNew)
-------------------------
Return an instance of asked module. If it is asked first time, it will create new instance and return in.
If an instance already exists, it will return that instance back. (if forceNew is not set to true). Dependencies will be resolved automatically.**Parameters**
**moduleName**: *string*, module name
**forceNew**: *boolean*, force creating new instance. By default it's false
**Returns**
*object*, module instance
getCustomInstance(moduleName, \[dependencies...\])
--------------------------------------------------
Return a new instance of asked module by calling the constructor with given dependencies. Use for testing purposes**Parameters**
**moduleName**: *string*, module name
**[dependencies...]**: *object...*, module dependencies (instances). For manual dependency resolving.
**Returns**
*object*, module instance