Skip to content

jshawl/dependency-injection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

"Dependency injection" is a somewhat scary term to explain loading modules and making sure memory footprint is minimal.

I've been thinking a lot about Angular's $injector and how I might build a dependency injector from scratch.

A thing that creates things

À la angular, I wanted an injector as the global namespace, a module method that allows me to both read and create modules. Let's start with creating a module.

We want the interface to be something like

injector.module("egg",[],{
  hatch: function(){
    console.log("chirp chirp")
  }
})

Where the name of the module is the first argument, the second argument is an array of dependencies, and the third argument is the module's prototype.

var injector = {
  module: function(name, dependencies, prototype){


  }
}

If there is only the first argument, the injector returns the module's prototype.

injector.module("egg").hatch()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published