Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Chefkoch containerjs

This repository provides Chefkoch's preferred dependency injection container for javascript. It is a simple wrapper for the great bottle.js, that has an interface more familiar to our developers that mostly work with php and the Symfony dependency injection container.

Usage

To use Chefkoch's containerjs you can install it via npm/yarn:

yarn add chefkoch-containerjs

We strongly recommend you use yarn but you can also use npm install <package…>.

Afterwards, you can start using the container in your javascript code:

importcontainerfrom'chefkoch-containerjs';// Define some constructorsfunctionKnife(){this.cut=(food)=>console.log(food);}functionCook(knife){this.prepareMeal=(foods)=>ingredients.forEach(food=>knife.cut(food));}// Register those constructors as servicescontainer.service('knife',Knife);container.service('cook',Cook,'knife');// Or use them inside of factories for more complex stuffcontainer.factory('another-cook',c=>{// Get the names of all registered servicesconstserviceNames=c.list();// Get other servicesconstknife=c.get('knife');returnnewCook(knife);});// Use your services...constcook=container.get('cook');cook.prepareMeal(['Tomato','Cucumber']);

About

A wrapper for bottlejs to enhance its interface.

Resources

Stars

2 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages