InversifyJS

2018-07-04 04:40:14 +0000 - Written by Carl Burks

I like to play around with new libraries in my spare time, and I was looking for something to handle IoC in JavaScript without writing my own. I checked with the interwebs and they suggested InversifyJS. So I followed the directions and installed it with node. I got it up and running with a minimum of fuss.

My tsconfig.json has two very important “compilerOptions”:

        "experimentalDecorators":true,
        "emitDecoratorMetadata": true

These get rid of the node warnings and let the decorators work.

In my project I was able to inject a data provider so I could switch between the node “fs” to read local json files and an $.ajax request to a webservice for data.