npm install @hkfrei/iocjs
Define the ioc container in your main JavaScript entry file.
// main.js
import IocContainer from "@hkfrei/iocjs"
const appIoc = new IocContainer()
register a transient class
appIoc.register({ name:"urlGateway", definition:UrlGateway });
register a transient class with initial values in the constructor
appIoc.register({ name: "initValue", definition:{ score:1 } })
appIoc.register({ name:"urlGateway", definition:UrlGateway, dependencies:["initValue"] });
register a transient class with dependecy classes
appIoc.register({ name:"urlGateway", definition:UrlGateway, dependencies:["initValue"] });
appIoc.register({ name:"mapPm", definition:MapPm, dependencies:["urlGateway] })
register a singleton
appIoc.register({ name:"urlGateway", definition:UrlGateway, singleton:true });
You can get instances of the registered classes the following way.
const mapPm = appIoc.get("mapPm")
npm run test
Launches the test runner in the interactive watch mode.
npm run build
Builds the app for production to the dist
folder.
For a full list of used libraries, have a look at package.json
Contributions are welcome! Please reach out to [email protected] if you want to have more information.
This project is Licensed under the GNU GENERAL PUBLIC License. See LICENSE.
Karten-werk GmbH Hanskaspar Frei [email protected]