HumanBreak/docs/api/class/resource-controller.md
2024-03-01 19:52:30 +08:00

64 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 抽象类 ReousrceController
渲染进程类,游戏进程不能直接使用,继承自 [`EventEmitter`](./event-emitter.md)
- 实例成员
- [`list`](#list)
- 实例方法
- [`abstract add`](#abstract-add)
- [`remove`](#remove)
- 实例事件
- [`add`](#add-事件)
- [`remove`](#remove-事件)
## list
```ts
declare var list: Record<string, any>
```
- 成员说明
存储了每个资源的信息,键为资源的 uri值为资源的数据
## abstract add()
```ts
declare function add(uri: string, data: any): void
```
- 参数说明
- `uri`: 资源的唯一标识符Unique Resource Identifier
- `data`: 资源数据
- 方法说明
添加一个资源
## remove()
```ts
declare function remove(uri: string): void
```
- 方法说明
根据 uri 删除一个资源
## add 事件
```ts
interface ResourceControllerEvent {
add: (uri: string, data: D) => void
}
```
## remove 事件
```ts
interface ResourceControllerEvent {
delete: (uri: string, content: T) => void
}
```