Skip to content

Commit

Permalink
docs: named-bean
Browse files Browse the repository at this point in the history
  • Loading branch information
zhennann committed Oct 3, 2024
1 parent f4a2a72 commit 02c408b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
16 changes: 1 addition & 15 deletions zova-docs/guide/essentials/ioc/named-bean.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,7 @@ export class StoreUserInfo {}
- containerScope
- Optional
- Default: `ctx`
- When injecting this bean into other bean instances, if containerScope is not explicitly specified, the value specified here is used

## Bean Identifier

In Zova, a module is a natural bundle boundary, and automatically bundled into an independent asynchronous chunk when building

Therefore, when using `named bean` cross-module, we do not recommend injecting directly based on `type`, but rather on `identifier`

The system will automatically assign an identifier to each `named bean` as the following format:

```bash
{moduleName}.{scene}.{name}
```

For example, the previously created store bean `userInfo` corresponds to the identifier `demo-basic.store.userInfo`, where `demo-basic` is the module name which `userInfo` belongs to
- When injecting this bean into other bean instances, if `injectionScope` is not explicitly specified, the value specified here is used

## Decorator list

Expand Down
16 changes: 1 addition & 15 deletions zova-docs/zh/guide/essentials/ioc/named-bean.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,7 @@ export class StoreUserInfo {}
- containerScope
- Optional
- 缺省值:ctx
- 在其他 Bean 实例中注入本 Bean 时,如果没有明确指定 containerScope,就使用这里指定的值

## Bean标识

在 Zova 中,一个模块就是一个天然的拆包边界,在 build 构建时,自动打包成一个独立的异步 Chunk

因此,在跨模块使用`具名bean`时,我们不建议直接`基于类型`注入,而是`基于标识`注入

系统会为每一个`具名bean`自动分配一个标识,格式如下:

```bash
{moduleName}.{scene}.{name}
```

比如,前面创建的 store bean `userInfo`,对应的标识为:`demo-basic.store.userInfo`,其中`demo-basic``userInfo`所归属的模块名称
- 在其他 Bean 实例中注入本 Bean 时,如果没有明确指定`injectionScope`,就使用这里指定的值

## 装饰器清单

Expand Down

0 comments on commit 02c408b

Please sign in to comment.