Example
deepdancer has a demo project, you will not see much code here but link to this project.
From scratch
The master branch does not use dependency injection, the deepdancer-darkmagic branch uses deepdancer-darkmagic.
By comparing the two branches you can get the essence of what deepdancer-darkmagic brings to your project. We suggest that you at read first deepdancer example before diving here.
From deepdancer
If you have already understood deepdancer.
The master branch uses deepdancer, the deepdancer-darkmagic branch uses deepdancer-darkmagic.
Quickly check how configuring deepdancer is affected by deepdancer-darkmagic
comparing
dependencies.js@deepdancer
and
dependencies.js@deepdancer-darkmagic:
- deepdancer-darkmagic literraly replaces deepdancer.
- We need to register dependencies’s alias, this enables us to treat
deepdancer-demo/service/user/upsertUser
asupsertUser
. Note that this is a suitable function parameter name. - Similarily, we alias also external dependencies to potential function
parameter names, for example
fs-promise
tofsPromise
.
Now this all start to makes sense when we look at one service upsertUser.js@deepdancer-darkmagic (for reference here is upsertUser.js@deepdancer):
- The
__dependencies
array is not required anymore. - The functions parameters names are used as dependencies name in the container.