Skip to content

Commit 8ddb3f6

Browse files
authored
docs: remove inversify-inject-decorators references (#1681)
1 parent f10c992 commit 8ddb3f6

File tree

4 files changed

+5
-64
lines changed

4 files changed

+5
-64
lines changed

wiki/circular_dependencies.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Circular dependencies
22

3-
## Circular dependencies in your modules (ES6, CommonJS, etc.)
3+
## Circular dependencies in your modules (ESM, CommonJS)
44

55
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:
66

77
> @inject called with undefined this could mean that the class ${name} has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation.
88
9-
There are two ways to overcome this limitation:
9+
There's a way to overcome this limitation:
1010

1111
- Use a `LazyServiceIdentifier`. 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).
1212

13-
- 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.
14-
1513
## Circular dependencies in the dependency graph (classes)
1614

1715
InversifyJS is able to identify circular dependencies and will throw an exception to help you to identify the location of the problem if a circular dependency is detected:

wiki/classes_as_id.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ An exception:
6666
Will be thrown if we use classes as identifiers in circular dependencies. For example:
6767

6868
```ts
69-
import { Container, injectable } from "inversify";
70-
import getDecorators from "inversify-inject-decorators";
69+
import { Container, injectable, inject } from "inversify";
7170

7271
let container = new Container();
73-
let { lazyInject } = getDecorators(container);
7472

7573
@injectable()
7674
class Dom {
@@ -82,7 +80,7 @@ class Dom {
8280

8381
@injectable()
8482
class DomUi {
85-
@lazyInject(Dom) public dom: Dom;
83+
@inject(Dom) public dom: Dom;
8684
}
8785

8886
@injectable()
@@ -103,10 +101,8 @@ The solution is to use symbols like `Symbol.for("Dom")` as service identifiers i
103101

104102
```ts
105103
import { Container, injectable, inject } from "inversify";
106-
import getDecorators from "inversify-inject-decorators";
107104

108105
const container: Container = new Container();
109-
const { lazyInject } = getDecorators(container);
110106

111107
const TYPE = {
112108
Dom: Symbol.for("Dom"),
@@ -128,7 +124,7 @@ class DomUi {
128124
@injectable()
129125
class Dom {
130126
public name: string;
131-
@lazyInject(TYPE.DomUi) public domUi: DomUi;
127+
@inject(TYPE.DomUi) public domUi: DomUi;
132128
constructor() {
133129
this.name = "Dom";
134130
}

wiki/ecosystem.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Consider these the “staff picks”, and don’t hesitate to submit a PR if you
77

88
### Utilities
99
- [inversify-binding-decorators](https://github.com/inversify/inversify-binding-decorators) - Allows developers to declare InversifyJS bindings using decorators.
10-
- [inversify-inject-decorators](https://github.com/inversify/inversify-inject-decorators) - Allows developers to declare lazy evaluated property injection using decorators.
1110
- [inversify-express-utils](https://github.com/inversify/inversify-express-utils) - Some utilities for the development of express application with Express.
1211
- [inversify-restify-utils](https://github.com/inversify/inversify-restify-utils) - Some utilities for the development of express application with Restify.
1312
- [inversify-vanillajs-helpers](https://github.com/inversify/inversify-vanillajs-helpers) - Some helpers for the development of InversifyJS applications with VanillaJS or Babel.

wiki/property_injection.md

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -79,55 +79,3 @@ create the instances of the classes in an application.
7979

8080
The problem is that some frameworks take the control over the creation of instances.
8181
For example, React takes control over the creation of instances of a given Component.
82-
83-
We have developed an utility that allows you to inject into a property even when
84-
InversifyJS has not created its instances:
85-
86-
```ts
87-
import getDecorators from "inversify-inject-decorators";
88-
import { Container, injectable } from "inversify";
89-
90-
@injectable()
91-
class PrintService {
92-
// ...
93-
}
94-
95-
let container = new Container();
96-
container.bind<PrintService>("PrintService").to(PrintService);
97-
let { lazyInject } = getDecorators(container);
98-
99-
class Book {
100-
101-
private _author: string;
102-
private _summary: string;
103-
104-
@lazyInject("PrintService")
105-
private _printService: PrintService;
106-
107-
constructor(author: string, summary: string) {
108-
this._author = author;
109-
this._summary = summary;
110-
}
111-
112-
public print() {
113-
this._printService.print(this);
114-
}
115-
116-
}
117-
118-
// Book instance is NOT created by InversifyJS
119-
let book = new Book("Title", "Summary");
120-
book.print();
121-
```
122-
123-
The utility module is called `inversify-inject-decorators`
124-
and provides the following decorators:
125-
126-
- `@lazyInject` for the injection of a property without metadata
127-
- `@lazyInjectNamed` for the injection of a property without named metadata.
128-
- `@lazyInjectTagged` for the injection of a property without tagged metadata.
129-
- `@lazyMultiInject` for multi-injections.
130-
131-
Please visit the module
132-
[project on GitHub](https://github.com/inversify/inversify-inject-decorators)
133-
to learn more.

0 commit comments

Comments
 (0)