Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Jan 19, 2024
1 parent 063467f commit e69637c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
28 changes: 27 additions & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- [Install](#install)
- [Quick Start](#quick-start)
- [API](#API)
- [API](#api)
- [Examples](#examples)
- [FAQ](#faq)
- [Related Efforts](#related-efforts)
Expand All @@ -18,6 +18,32 @@ npm install @opensumi/di --save
yarn add @opensumi/di
```

将您的tsconfig.json修改为包含以下设置:

```json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
```

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

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

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

```typescript
// main.ts
import "reflect-metadata";

// 你的代码...
```

## Quick Start

让我们从一个简单的例子开始:
Expand Down
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,44 @@ This tool will help you achieve dependency inversion effectively without concern

- [Install](#install)
- [Quick Start](#quick-start)
- [API](#API)
- [API](#api)
- [Examples](#examples)
- [FAQ](#faq)
- [Related Efforts](#related-efforts)

## Install
## Installation

```sh
npm install @opensumi/di --save
yarn add @opensumi/di
```

Modify your tsconfig.json to include the following settings:

```json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
```

Add a polyfill for the Reflect API (examples below use reflect-metadata). You can use:

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

The Reflect polyfill import should only be added once, and before DI is used:

```typescript
// main.ts
import "reflect-metadata";

// Your code here...
```

## Quick Start

Let's start with a simple example:
Expand Down

0 comments on commit e69637c

Please sign in to comment.