lite-ts-user-child
v11.1.1
Published
```typescript const manager: UserChildManagerBase<UserChild, UserChildManagerAddOption<UserChild>, UserChildManagerRemoveOption<UserChild>>;
Downloads
84
Readme
代码
UserChildManagerBase<TEntry extends UserChild, TAddOption extends UserChildManagerAddOption<TEntry>, TRemoveOption extends UserChildManagerRemoveOption<TEntry>> - 玩家子服务管理
const manager: UserChildManagerBase<UserChild, UserChildManagerAddOption<UserChild>, UserChildManagerRemoveOption<UserChild>>;
// 获取所有子服务
const res = await manager.all;
// res = { [no: number]: UserChildService<T>; }
// 清除子服务缓存
manager.flush();
// 添加子服务
const partialEntry: Omit<UserChild, 'id' | 'no' | 'userID'>;
const res = await manager.add({
partialEntry,
});
// res = 新增的子服务
const childService: UserChildService<UserChild>;
await manager.remove({
childService: childService,
});
- DbUserChildManager<T extends UserChild> - 数据库实现
const dbFactory: DbFactoryBase;
const stringGenerator: StringGeneratorBase;
const userService: IUserService;
const buildGetCountValueHandlerFunc: UserChildValueHandlerDelegate<T>;
const buildUpdateValueHandlerFunc: UserChildValueHandlerDelegate<T>;
const manager: UserChildManagerBase<UserChild, DbUserChildManagerAddOption<UserChild>, DbUserChildManagerRemoveOption<UserChild>> = new DbUserChildManager(
dbFactory,
stringGenerator,
UserChild,
userService,
buildGetCountValueHandlerFunc,
buildUpdateValueHandlerFunc,
);
- RpcUserChildManager<T extends UserChild> - rpc实现
const rpc: RpcBase;
const findEntriesRpcOption: RpcCallOption<UserChild[]>;
const userService: IUserService;
const buildGetCountValueHandlerFunc: UserChildValueHandlerDelegate<T>;
const buildUpdateValueHandlerFunc: UserChildValueHandlerDelegate<T>;
const manager: UserChildManagerBase<UserChild, DbUserChildManagerAddOption<UserChild>, DbUserChildManagerRemoveOption<UserChild>> = new RpcUserChildManager(
rpc,
findEntriesRpcOption,
UserChild,
userService,
buildGetCountValueHandlerFunc,
buildUpdateValueHandlerFunc,
);
UserChildService<T extends UserChild> - 玩家子服务
const service: UserChildService<UserChild>;
// 数据
const res = service.entry;
// 玩家服务
const res = service.userService;
// 数值服务
const res = service.valueService;
UserChildValueService<T extends UserChild> - 玩家子数值服务
const valueService: UserChildValueService<UserChild>;
// 子服务
const res = valueService.childService;