Skip to content

Commit dd62cf1

Browse files
committed
docs: update README
1 parent 329dfcd commit dd62cf1

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

README-zh_CN.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ npm install @opensumi/di --save
1818
yarn add @opensumi/di
1919
```
2020

21-
将您的tsconfig.json修改为包含以下设置
21+
将您的 tsconfig.json 修改为包含以下设置
2222

2323
```json
2424
{
@@ -29,17 +29,17 @@ yarn add @opensumi/di
2929
}
3030
```
3131

32-
为Reflect API添加一个polyfill(下面的例子使用reflect-metadata)。你可以使用:
32+
为 Reflect API 添加一个 polyfill(下面的例子使用 reflect-metadata)。你可以使用:
3333

3434
- [reflect-metadata](https://www.npmjs.com/package/reflect-metadata)
3535
- [core-js (core-js/es7/reflect)](https://www.npmjs.com/package/core-js)
3636
- [reflection](https://www.npmjs.com/package/@abraham/reflection)
3737

38-
Reflect polyfill的导入应该只添加一次,并且在使用DI之前
38+
Reflect polyfill 的导入应该只添加一次,并且在使用 DI 之前
3939

4040
```typescript
4141
// main.ts
42-
import "reflect-metadata";
42+
import 'reflect-metadata';
4343

4444
// 你的代码...
4545
```
@@ -454,6 +454,12 @@ console.log(b.a instanceof A); // print 'true'
454454

455455
Whether have an instantiated object in the Injector.
456456

457+
### Injector.disposeOne / Injector.disposeAll
458+
459+
可以使用 `Injector.disposeOne``Injector.disposeAll` 来释放 Token。
460+
461+
这两个方法会从 DI 容器中删除当前已创建的实例,并尝试调用这个实例的 `dispose` 方法(可以没有)。
462+
457463
### markInjectable
458464

459465
```ts

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
[test-image]: https://codecov.io/gh/opensumi/di/branch/main/graph/badge.svg?token=07JAPLU957
1414
[test-url]: https://codecov.io/gh/opensumi/di
1515
[pkg-size]: https://pkg-size.dev/@opensumi/di
16-
[pkg-size-img]: https://pkg-size.dev/badge/bundle/43685
17-
18-
> Inspired By [Angular](https://angular.io/guide/dependency-injection).
16+
[pkg-size-img]: https://pkg-size.dev/badge/bundle/15776
1917

2018
This tool will help you achieve dependency inversion effectively without concerning the details of object instantiation. Additionally, since object instantiation is done within a registry, both the factory pattern and singleton pattern can be easily implemented.
2119

@@ -56,7 +54,7 @@ The Reflect polyfill import should only be added once, and before DI is used:
5654

5755
```typescript
5856
// main.ts
59-
import "reflect-metadata";
57+
import 'reflect-metadata';
6058

6159
// Your code here...
6260
```
@@ -475,6 +473,12 @@ console.log(b.a instanceof A); // print 'true'
475473

476474
Whether have an instantiated object in the Injector.
477475

476+
### Injector.disposeOne / Injector.disposeAll
477+
478+
You can use `Injector.disposeOne` to dispose of a specific instance, and `Injector.disposeAll` to dispose of all instances.
479+
480+
These two methods will delete the instance from the Injector, and then call the `dispose` method of the instance if it exists.
481+
478482
### markInjectable
479483

480484
```ts

0 commit comments

Comments
 (0)