restartToExecute中的小问题
This commit is contained in:
parent
9048839a1b
commit
fab7e35537
|
|
@ -50,7 +50,7 @@ export declare abstract class AsyncContext<ED extends EntityDict> implements Con
|
|||
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
|
||||
abstract setCurrentUserId(userId: string | undefined): void;
|
||||
abstract toString(): Promise<string>;
|
||||
abstract getSerializedData(): object;
|
||||
abstract getSerializedData(): Promise<object>;
|
||||
abstract initialize(data?: any, later?: boolean): Promise<void>;
|
||||
abstract allowUserUpdate(): boolean;
|
||||
abstract openRootMode(): () => void;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ class AsyncContext {
|
|||
}
|
||||
// 使一个上下文重新开始事务执行,清除历史数据(定时器中使用)
|
||||
async restartToExecute(routine) {
|
||||
const data = this.getSerializedData();
|
||||
const newContext = (new (Object.getPrototypeOf(this).constructor)());
|
||||
const data = await this.getSerializedData();
|
||||
const newContext = (new (Object.getPrototypeOf(this).constructor)(this.rowStore));
|
||||
await newContext.initialize(data, true);
|
||||
newContext.opRecords = [];
|
||||
newContext.events = {
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ export abstract class AsyncContext<ED extends EntityDict> implements Context {
|
|||
|
||||
// 使一个上下文重新开始事务执行,清除历史数据(定时器中使用)
|
||||
async restartToExecute(routine: (context: this) => Promise<any>) {
|
||||
const data = this.getSerializedData();
|
||||
const newContext = (new (Object.getPrototypeOf(this).constructor)()) as typeof this;
|
||||
const data = await this.getSerializedData();
|
||||
const newContext = (new (Object.getPrototypeOf(this).constructor)(this.rowStore)) as typeof this;
|
||||
await newContext.initialize(data, true);
|
||||
|
||||
newContext.opRecords = [];
|
||||
|
|
@ -230,7 +230,7 @@ export abstract class AsyncContext<ED extends EntityDict> implements Context {
|
|||
// 此接口将上下文变成可以serialized的字符串
|
||||
abstract toString(): Promise<string>;
|
||||
|
||||
abstract getSerializedData(): object;
|
||||
abstract getSerializedData(): Promise<object>;
|
||||
|
||||
// 此接口将字符串parse成对象再进行初始化
|
||||
// later表示允许延时状态,上下文要处理在时间维度上可能的异常(比如用户token已经注销等)
|
||||
|
|
|
|||
Loading…
Reference in New Issue