removed spaces from api file

This commit is contained in:
Alex Wolfe 2015-04-22 08:36:45 -07:00
parent 787cb70460
commit 0ab35c0735
1 changed files with 42 additions and 42 deletions

View File

@ -5,52 +5,52 @@ p.location-badge.
:markdown :markdown
A dependency injection container used for resolving dependencies. A dependency injection container used for resolving dependencies.
An `Injector` is a replacement for a `new` operator, which can automatically resolve the constructor dependencies. An `Injector` is a replacement for a `new` operator, which can automatically resolve the constructor dependencies.
In typical use, application code asks for the dependencies in the constructor and they are resolved by the In typical use, application code asks for the dependencies in the constructor and they are resolved by the
`Injector`. `Injector`.
## Example: ## Example:
Suppose that we want to inject an `Engine` into class `Car`, we would define it like this: Suppose that we want to inject an `Engine` into class `Car`, we would define it like this:
```javascript ```javascript
class Engine { class Engine {
} }
class Car { class Car {
constructor(@Inject(Engine) engine) { constructor(@Inject(Engine) engine) {
} }
} }
``` ```
Next we need to write the code that creates and instantiates the `Injector`. We then ask for the `root` object, Next we need to write the code that creates and instantiates the `Injector`. We then ask for the `root` object,
`Car`, so that the `Injector` can recursively build all of that object's dependencies. `Car`, so that the `Injector` can recursively build all of that object's dependencies.
```javascript ```javascript
main() { main() {
var injector = Injector.resolveAndCreate([Car, Engine]); var injector = Injector.resolveAndCreate([Car, Engine]);
// Get a reference to the `root` object, which will recursively instantiate the tree. // Get a reference to the `root` object, which will recursively instantiate the tree.
var car = injector.get(Car); var car = injector.get(Car);
} }
``` ```
Notice that we don't use the `new` operator because we explicitly want to have the `Injector` resolve all of the Notice that we don't use the `new` operator because we explicitly want to have the `Injector` resolve all of the
object's dependencies automatically. object's dependencies automatically.
.l-main-section .l-main-section
h2 Members h2 Members
.l-sub-section .l-sub-section
h3 constructor h3 constructor
pre.prettyprint pre.prettyprint
code. code.
constructor(bindings:List<ResolvedBinding>, parent:Injector, defaultBindings:boolean, [object Object], [object Object], [object Object]) constructor(bindings:List<ResolvedBinding>, parent:Injector, defaultBindings:boolean, [object Object], [object Object], [object Object])
:markdown :markdown
@ -58,14 +58,14 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 asyncGet h3 asyncGet
pre.prettyprint pre.prettyprint
code. code.
asyncGet(token, [object Object]) asyncGet(token, [object Object])
:markdown :markdown
Retrieves an instance from the injector asynchronously. Used with asynchronous bindings. Retrieves an instance from the injector asynchronously. Used with asynchronous bindings.
@ -74,14 +74,14 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 createChildFromResolved h3 createChildFromResolved
pre.prettyprint pre.prettyprint
code. code.
createChildFromResolved(bindings:List<ResolvedBinding>, [object Object]) createChildFromResolved(bindings:List<ResolvedBinding>, [object Object])
:markdown :markdown
Creates a child injector and loads a new set of <a href="angular2/di/ResolvedBinding-class"><code>ResolvedBinding</code></a>s into it. Creates a child injector and loads a new set of <a href="angular2/di/ResolvedBinding-class"><code>ResolvedBinding</code></a>s into it.
@ -90,15 +90,15 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 fromResolvedBindings h3 fromResolvedBindings
pre.prettyprint pre.prettyprint
code. code.
fromResolvedBindings(bindings:List&lt;ResolvedBinding&gt;, {defaultBindings=false}={}, [object Object], [object Object]) fromResolvedBindings(bindings:List&lt;ResolvedBinding&gt;, {defaultBindings=false}={}, [object Object], [object Object])
:markdown :markdown
Creates an injector from previously resolved bindings. This bypasses resolution and flattening. This API is the Creates an injector from previously resolved bindings. This bypasses resolution and flattening. This API is the
recommended way to construct injectors in performance-sensitive parts. recommended way to construct injectors in performance-sensitive parts.
@ -107,14 +107,14 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 get h3 get
pre.prettyprint pre.prettyprint
code. code.
get(token, [object Object]) get(token, [object Object])
:markdown :markdown
Retrieves an instance from the injector. Retrieves an instance from the injector.
@ -123,14 +123,14 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 getOptional h3 getOptional
pre.prettyprint pre.prettyprint
code. code.
getOptional(token, [object Object]) getOptional(token, [object Object])
:markdown :markdown
Retrieves an instance from the injector. Retrieves an instance from the injector.
@ -139,18 +139,18 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 resolve h3 resolve
pre.prettyprint pre.prettyprint
code. code.
resolve(bindings:List, [object Object]) resolve(bindings:List, [object Object])
:markdown :markdown
Turns a list of binding definitions into an internal resolved list of resolved bindings. Turns a list of binding definitions into an internal resolved list of resolved bindings.
A resolution is a process of flattening multiple nested lists and converting individual bindings into a A resolution is a process of flattening multiple nested lists and converting individual bindings into a
list of <a href="angular2/di/ResolvedBinding-class"><code>ResolvedBinding</code></a>s. The resolution can be cached by `resolve` for the <a href="angular2/di/Injector-class"><code>Injector</code></a> for list of <a href="angular2/di/ResolvedBinding-class"><code>ResolvedBinding</code></a>s. The resolution can be cached by `resolve` for the <a href="angular2/di/Injector-class"><code>Injector</code></a> for
performance-sensitive code. performance-sensitive code.
@ -159,18 +159,18 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 resolveAndCreate h3 resolveAndCreate
pre.prettyprint pre.prettyprint
code. code.
resolveAndCreate(bindings:List, {defaultBindings=false}={}, [object Object], [object Object]) resolveAndCreate(bindings:List, {defaultBindings=false}={}, [object Object], [object Object])
:markdown :markdown
Resolves bindings and creates an injector based on those bindings. This function is slower than the Resolves bindings and creates an injector based on those bindings. This function is slower than the
corresponding `fromResolvedBindings` because it needs to resolve bindings first. See `resolve` for the corresponding `fromResolvedBindings` because it needs to resolve bindings first. See `resolve` for the
<a href="angular2/di/Injector-class"><code>Injector</code></a>. <a href="angular2/di/Injector-class"><code>Injector</code></a>.
Prefer `fromResolvedBindings` in performance-critical code that creates lots of injectors. Prefer `fromResolvedBindings` in performance-critical code that creates lots of injectors.
@ -179,18 +179,18 @@ p.location-badge.
.l-sub-section .l-sub-section
h3 resolveAndCreateChild h3 resolveAndCreateChild
pre.prettyprint pre.prettyprint
code. code.
resolveAndCreateChild(bindings:List, [object Object]) resolveAndCreateChild(bindings:List, [object Object])
:markdown :markdown
Creates a child injector and loads a new set of bindings into it. Creates a child injector and loads a new set of bindings into it.
A resolution is a process of flattening multiple nested lists and converting individual bindings into a A resolution is a process of flattening multiple nested lists and converting individual bindings into a
list of <a href="angular2/di/ResolvedBinding-class"><code>ResolvedBinding</code></a>s. The resolution can be cached by `resolve` for the <a href="angular2/di/Injector-class"><code>Injector</code></a> for list of <a href="angular2/di/ResolvedBinding-class"><code>ResolvedBinding</code></a>s. The resolution can be cached by `resolve` for the <a href="angular2/di/Injector-class"><code>Injector</code></a> for
performance-sensitive code. performance-sensitive code.