Skip to content

Commit 4e6ca30

Browse files
authored
Ensure async usage of JsonOperationHandler.commandOf (#69)
Make runnable of command return a MaybePromise to be consistent with the doExecute method of recording commands and support async recordings.
1 parent 6db8ac8 commit 4e6ca30

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/server/src/common/operations/json-operation-handler.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export namespace JsonModelState {
5555
* to the `sourceModel` of the given {@link JsonModelState} during the given `doExecute` function
5656
*/
5757
export class JsonRecordingCommand<JsonObject extends AnyObject = AnyObject> extends AbstractRecordingCommand<JsonObject> {
58-
constructor(protected modelState: JsonModelState<JsonObject>, protected doExecute: () => MaybePromise<void>) {
58+
constructor(
59+
protected modelState: JsonModelState<JsonObject>,
60+
protected doExecute: () => MaybePromise<void>
61+
) {
5962
super();
6063
}
6164

@@ -75,7 +78,7 @@ export class JsonRecordingCommand<JsonObject extends AnyObject = AnyObject> exte
7578
*/
7679
@injectable()
7780
export abstract class JsonOperationHandler extends OperationHandler {
78-
protected commandOf(runnable: () => void): Command {
81+
protected commandOf(runnable: () => MaybePromise<void>): Command {
7982
if (!JsonModelState.is(this.modelState)) {
8083
throw new Error('Cannot create command. The underlying model state does not implement the `JsonModelState` interface');
8184
}
@@ -99,8 +102,10 @@ export abstract class JsonCreateNodeOperationHandler extends JsonOperationHandle
99102
}
100103

101104
protected createTriggerNodeCreationAction(elementTypeId: string): TriggerNodeCreationAction {
102-
return TriggerNodeCreationAction.create(elementTypeId,
103-
{ ghostElement: this.createTriggerGhostElement(elementTypeId), args: this.createTriggerArgs(elementTypeId) } );
105+
return TriggerNodeCreationAction.create(elementTypeId, {
106+
ghostElement: this.createTriggerGhostElement(elementTypeId),
107+
args: this.createTriggerArgs(elementTypeId)
108+
});
104109
}
105110

106111
protected createTriggerGhostElement(elementTypeId: string): GhostElement | undefined {

0 commit comments

Comments
 (0)