Browse files

break out core injector so it can be used without steal or JMVC

  • Loading branch information...
1 parent 53a5463 commit 9bd33be887a306f14a0f6eb1147cb6b608ead528 @iamnoah committed Apr 21, 2012
Showing with 659 additions and 523 deletions.
  1. +4 −2
  2. +268 −225
  3. +374 −296 inject-core.js
  4. +4 −0
  5. +9 −0 inject.js
@@ -1,12 +1,14 @@
[What is dependency injection?](
-# Functional Dependency Injection for JavaScriptMVC
+# Functional Dependency Injection for JavaScriptMVC (DoneJS/CanJS)
In a traditional dependency injection paradigm, the container manages objects that are connected to each other through the wiring spec. Injection is done by either setting properties or passing values to a constructor function (which typically then sets the properties on the object itself).
While that is a paradigm that works well in object oriented languages, it's more natural in a functional language like JavaScript to inject functions instead.
+**NOTE:** inject-core.js can be used independently of JavaScript MVC. You obviously wont be able to use the Class and Controller based functionality, but named functions and everything else should work.
## Advantages of injecting functions instead of objects
* No mutable state - no objects are modified, so it isn't possible for keys names to conflict or for injected values to be changed.
@@ -30,7 +32,7 @@ Injector definitions are simple objects with a `name` and a `factory` function.
In the examples, we name the injector variable `injector`, but you can call it whatever you want. e.g., `require`, `when`, `myInjector`, etc. The injector is also referred to as the context.
-**NOTE:** these docs are a work in progress, but for working examples of all functionality, you can refer to the qunit tests in the test directory.
+**NOTE:** these docs fairly complete, but you can always find working examples in the qunit tests in the test directory.
## Injecting plain functions
Oops, something went wrong.

0 comments on commit 9bd33be

Please sign in to comment.