mirror of
https://github.com/motajs/template.git
synced 2026-10-16 10:30:18 +08:00
chore: 调整加载接口
This commit is contained in:
parent
2f3d3387a0
commit
d1ebca0b16
@ -204,7 +204,7 @@ export class CoreState implements ICoreState {
|
||||
|
||||
//#region 初始化方法
|
||||
|
||||
async *load(): AsyncIterator<number, void> {
|
||||
async *load(): AsyncGenerator<number, void> {
|
||||
await this.initialize();
|
||||
yield* this.loader.start();
|
||||
await this.afterLoad();
|
||||
|
||||
@ -107,7 +107,7 @@ export interface ICoreState
|
||||
/**
|
||||
* 执行数据端主对象的加载行为,并进行必要的初始化
|
||||
*/
|
||||
load(): AsyncIterator<number, void>;
|
||||
load(): AsyncGenerator<number, void>;
|
||||
|
||||
/**
|
||||
* 将某个存档执行器绑定至指定的可存档对象,一个可存档对象只能绑定一个执行器,
|
||||
|
||||
@ -22,14 +22,11 @@ export function createCoreStateConfig(
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据端主对象,返回经过初始化的主对象实例
|
||||
* 创建数据端主对象,返回未经过初始化的主对象实例,需要手动调用 `state.load` 初始化
|
||||
* @param starter 加载启动器
|
||||
*/
|
||||
export async function createCoreState(
|
||||
starter: ILoadTaskStarter
|
||||
): Promise<ICoreState> {
|
||||
export function createCoreState(starter: ILoadTaskStarter): ICoreState {
|
||||
const config = createCoreStateConfig(starter);
|
||||
const state = new CoreState(config);
|
||||
await state.load();
|
||||
return state;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user