存储池
预计阅读时间: 小于 1 分钟
createStorePool - (function)
创建存储池, 返回存储池操作方法, 用于存储数据, 内部通过索引管理, 存储数据时会返回 id, 会自动维护索引, 自动扩容
参数
必填 | 参数 | 说明 | 类型 | 默认值 |
---|
| controller | 存储控制器 | IStoreController | DefaultStoreController |
类型补充
IStoreController
1interface IStoreController {
2 save: (data: any) => number;
3 get: (id: number) => any;
4 delete: (id: number) => void;
5 clear: () => void;
6 pop: (id: number) => any;
7}
返回值
IStorePoolHandle
对象
类型补充
IStorePoolHandle
1interface IStorePoolHandle {
2 // 存储
3 save: (value: any) => number;
4 // 获取
5 get: (id: number) => any;
6 // 删除
7 delete: (id: number) => void;
8 // 清空
9 clear: () => void;
10 // 弹出
11 pop: (id: number) => any;
12 // 监听
13 on: (type: string, listener: Function) => Function;
14 // 取消监听
15 off: (type: string, listener: Function) => void;
16 // 监听一次
17 once: (type: string, listener: Function) => Function;
18 // 清空监听
19 clearEvent: (type: string) => void;
20 // 清空监听
21 clearEvents: () => void;
22}