@@ -29,9 +29,9 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
2929 protected redoPatch ?: jsonPatch . Operation [ ] ;
3030
3131 async execute ( ) : Promise < void > {
32- const beforeState = this . deepClone ( this . getJsonObject ( ) ) ;
32+ const beforeState = this . deepClone ( await this . getJsonObject ( ) ) ;
3333 await this . doExecute ( ) ;
34- const afterState = this . getJsonObject ( ) ;
34+ const afterState = await this . getJsonObject ( ) ;
3535 this . undoPatch = jsonPatch . compare ( afterState , beforeState ) ;
3636 this . redoPatch = jsonPatch . compare ( beforeState , afterState ) ;
3737 }
@@ -41,14 +41,14 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
4141 * right after {@link AbstractRecordingCommand.doExecute} to derive the undo & redo patches.
4242 * @returns The current state of the JSON object
4343 */
44- protected abstract getJsonObject ( ) : JsonObject ;
44+ protected abstract getJsonObject ( ) : MaybePromise < JsonObject > ;
4545
4646 /**
4747 * The actual execution i.e. series of changes applied to the JSOn object that should be captured.
4848 */
4949 protected abstract doExecute ( ) : MaybePromise < void > ;
5050
51- protected applyPatch ( object : JsonObject , patch : jsonPatch . Operation [ ] ) : void {
51+ protected applyPatch ( object : JsonObject , patch : jsonPatch . Operation [ ] ) : MaybePromise < void > {
5252 jsonPatch . applyPatch ( object , patch , false , true ) ;
5353 }
5454
@@ -62,15 +62,15 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
6262 return jsonPatch . deepClone ( object ) ;
6363 }
6464
65- undo ( ) : void {
65+ async undo ( ) : Promise < void > {
6666 if ( this . undoPatch ) {
67- this . applyPatch ( this . getJsonObject ( ) , this . undoPatch ) ;
67+ return this . applyPatch ( await this . getJsonObject ( ) , this . undoPatch ) ;
6868 }
6969 }
7070
71- redo ( ) : void {
71+ async redo ( ) : Promise < void > {
7272 if ( this . redoPatch ) {
73- this . applyPatch ( this . getJsonObject ( ) , this . redoPatch ) ;
73+ return this . applyPatch ( await this . getJsonObject ( ) , this . redoPatch ) ;
7474 }
7575 }
7676
@@ -88,7 +88,7 @@ export class RecordingCommand<JsonObject extends AnyObject = AnyObject> extends
8888 super ( ) ;
8989 }
9090
91- protected getJsonObject ( ) : JsonObject {
91+ protected getJsonObject ( ) : MaybePromise < JsonObject > {
9292 return this . jsonObject ;
9393 }
9494}
@@ -107,11 +107,11 @@ export class GModelRecordingCommand extends AbstractRecordingCommand<GModelRootS
107107 this . modelState . index . indexRoot ( this . modelState . root ) ;
108108 }
109109
110- protected getJsonObject ( ) : GModelRootSchema {
110+ protected getJsonObject ( ) : MaybePromise < GModelRootSchema > {
111111 return this . serializer . createSchema ( this . modelState . root ) ;
112112 }
113113
114- protected override applyPatch ( rootSchema : GModelRootSchema , patch : jsonPatch . Operation [ ] ) : void {
114+ protected override applyPatch ( rootSchema : GModelRootSchema , patch : jsonPatch . Operation [ ] ) : MaybePromise < void > {
115115 super . applyPatch ( rootSchema , patch ) ;
116116 const newRoot = this . serializer . createRoot ( rootSchema ) ;
117117 this . modelState . updateRoot ( newRoot ) ;
0 commit comments