@@ -43,7 +43,7 @@ class Car {
4343 }
4444}
4545
46- var inj = new Injector([
46+ var inj = Injector.resolveAndCreate ([
4747 bind(Car).toClass(Car),
4848 bind(Engine).toClass(Engine)
4949]);
@@ -86,7 +86,7 @@ To avoid bugs make sure the registered objects have side-effect-free constructor
8686Injectors are hierarchical.
8787
8888```
89- var child = injector.createChild ([
89+ var child = injector.resolveAndCreateChild ([
9090 bind(Engine).toClass(TurboEngine)
9191]);
9292
@@ -99,21 +99,21 @@ var car = child.get(Car); // uses the Car binding from the parent injector and E
9999You can bind to a class, a value, or a factory. It is also possible to alias existing bindings.
100100
101101```
102- var inj = new Injector([
102+ var inj = Injector.resolveAndCreate ([
103103 bind(Car).toClass(Car),
104104 bind(Engine).toClass(Engine)
105105]);
106106
107- var inj = new Injector([
107+ var inj = Injector.resolveAndCreate ([
108108 Car, // syntax sugar for bind(Car).toClass(Car)
109109 Engine
110110]);
111111
112- var inj = new Injector([
112+ var inj = Injector.resolveAndCreate ([
113113 bind(Car).toValue(new Car(new Engine()))
114114]);
115115
116- var inj = new Injector([
116+ var inj = Injector.resolveAndCreate ([
117117 bind(Car).toFactory((e) => new Car(e), [Engine]),
118118 bind(Engine).toFactory(() => new Engine())
119119]);
@@ -122,7 +122,7 @@ var inj = new Injector([
122122You can bind any token.
123123
124124```
125- var inj = new Injector([
125+ var inj = Injector.resolveAndCreate ([
126126 bind(Car).toFactory((e) => new Car(), ["engine!"]),
127127 bind("engine!").toClass(Engine)
128128]);
@@ -131,7 +131,7 @@ var inj = new Injector([
131131If you want to alias an existing binding, you can do so using ` toAlias ` :
132132
133133```
134- var inj = new Injector([
134+ var inj = Injector.resolveAndCreate ([
135135 bind(Engine).toClass(Engine),
136136 bind("engine!").toAlias(Engine)
137137]);
@@ -152,7 +152,7 @@ The `someFactory` function does not have to know that it creates an object for `
152152Injector can create binding on the fly if we enable default bindings.
153153
154154```
155- var inj = new Injector([], {defaultBindings: true});
155+ var inj = Injector.resolveAndCreate ([], {defaultBindings: true});
156156var car = inj.get(Car); //this works as if `bind(Car).toClass(Car)` and `bind(Engine).toClass(Engine)` were present.
157157```
158158
@@ -226,7 +226,7 @@ class UserController {
226226 }
227227}
228228
229- var inj = new Injector([
229+ var inj = Injector.resolveAndCreate ([
230230 bind(UserList).toAsyncFactory(() => fetchUsersUsingHttp().then((u) => new UserList(u))),
231231 UserController
232232])
@@ -252,7 +252,7 @@ class UserController {
252252 }
253253}
254254
255- var inj = new Injector([
255+ var inj = Injector.resolveAndCreate ([
256256 bind(UserList).toAsyncFactory(() => fetchUsersUsingHttp().then((u) => new UserList(u))),
257257 UserController
258258])
@@ -276,7 +276,7 @@ class UserController {
276276 constructor(ul:UserList){}
277277}
278278
279- var inj = new Injector([UserList, UserController]);
279+ var inj = Injector.resolveAndCreate ([UserList, UserController]);
280280var ctrl:UserController = inj.get(UserController);
281281```
282282
@@ -290,7 +290,7 @@ class UserController {
290290 constructor(@InjectPromise(UserList) ul){}
291291}
292292
293- var inj = new Injector([UserList, UserController]);
293+ var inj = Injector.resolveAndCreate ([UserList, UserController]);
294294var ctrl:UserController = inj.get(UserController);
295295// UserController responsible for dealing with asynchrony.
296296expect(ctrl.ul).toBePromise();
@@ -306,7 +306,7 @@ class UserController {
306306 constructor(ul:UserList){}
307307}
308308
309- var inj = new Injector([
309+ var inj = Injector.resolveAndCreate ([
310310 bind(UserList).toAsyncFactory(() => fetchUsersUsingHttp().then((u) => new UserList(u))),
311311 UserController
312312]);
@@ -331,7 +331,7 @@ class UserController {
331331 constructor(@InjectPromise(UserList) ul){}
332332}
333333
334- var inj = new Injector([
334+ var inj = Injector.resolveAndCreate ([
335335 bind(UserList).toAsyncFactory(() => fetchUsersUsingHttp().then((u) => new UserList(u))),
336336 UserController
337337]);
@@ -369,14 +369,14 @@ If we need a transient dependency, something that we want a new instance of ever
369369We can create a child injector:
370370
371371```
372- var child = inj.createChild ([MyClass]);
372+ var child = inj.resolveAndCreateChild ([MyClass]);
373373child.get(MyClass);
374374```
375375
376376Or we can register a factory function:
377377
378378```
379- var inj = new Injector([
379+ var inj = Injector.resolveAndCreate ([
380380 bind('MyClassFactory').toFactory(dep => () => new MyClass(dep), [SomeDependency])
381381]);
382382
@@ -393,7 +393,7 @@ expect(instance1).not.toBe(instance2);
393393Most of the time we do not have to deal with keys.
394394
395395```
396- var inj = new Injector([
396+ var inj = Injector.resolveAndCreate ([
397397 bind(Engine).toFactory(() => new TurboEngine()) //the passed in token Engine gets mapped to a key
398398]);
399399var engine = inj.get(Engine); //the passed in token Engine gets mapped to a key
@@ -404,7 +404,7 @@ Now, the same example, but with keys
404404```
405405var ENGINE_KEY = Key.get(Engine);
406406
407- var inj = new Injector([
407+ var inj = Injector.resolveAndCreate ([
408408 bind(ENGINE_KEY).toFactory(() => new TurboEngine()) // no mapping
409409]);
410410var engine = inj.get(ENGINE_KEY); // no mapping
0 commit comments