Skip to content

Commit

Permalink
Fix typos (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
Basemm authored and remojansen committed Jan 29, 2018
1 parent 0ff9130 commit 8b3d504
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wiki/circular_dependencies.md
Expand Up @@ -2,13 +2,13 @@

## Circular dependencies in your modules (ES6, CommonJS, etc.)

If you have a circular dependency between to modules and you use the `@inject(SomeClass)` annotation. At runtime, one module will be parsed before the other and the decorator could be invoked with `@inject(SomeClass /* SomeClass = undefined*/)`. InversifyJS will throw the following exception:
If you have a circular dependency between two modules and you use the `@inject(SomeClass)` annotation. At runtime, one module will be parsed before the other and the decorator could be invoked with `@inject(SomeClass /* SomeClass = undefined*/)`. InversifyJS will throw the following exception:

> @inject called with undefined this could mean that the class ${name} has a circular dependency problem. You can use a LazyServiceIdentifer to overcome this limitation.
There are two ways to overcome this limitation:

- Use a `LazyServiceIdentifer`. The lazy identifier doesn't delay the injection of the dependencies and all dependencies are injected when the class instance is created. However, it does deplay the access to the propery identifier (solving the module issue). An example of this can be found in [our unit tests](https://github.com/krzkaczor/InversifyJS/blob/a53bf2cbee65803b197998c1df496c3be84731d9/test/inversify.test.ts#L236-L300).
- Use a `LazyServiceIdentifer`. The lazy identifier doesn't delay the injection of the dependencies and all dependencies are injected when the class instance is created. However, it does delay the access to the property identifier (solving the module issue). An example of this can be found in [our unit tests](https://github.com/krzkaczor/InversifyJS/blob/a53bf2cbee65803b197998c1df496c3be84731d9/test/inversify.test.ts#L236-L300).

- Use the `@lazyInject` decorator. This decorator is part of the [`inversify-inject-decorators`](https://github.com/inversify/inversify-inject-decorators) module. The `@lazyInject` decorator delays the injection of the dependencies until they are actually used, this takes place after a class instance has been created.

Expand Down

0 comments on commit 8b3d504

Please sign in to comment.