Skip to content

Commit 77240fe

Browse files
committed
Use partial application via bind to clean up further
1 parent 5f78414 commit 77240fe

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/workflow/src/internals.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
WorkflowUpdateAnnotatedType,
1717
ProtoFailure,
1818
ApplicationFailure,
19+
WorkflowUpdateType,
20+
WorkflowUpdateValidatorType,
1921
} from '@temporalio/common';
2022
import { composeInterceptors } from '@temporalio/common/lib/interceptors';
2123
import { checkExtends } from '@temporalio/common/lib/type-helpers';
@@ -668,7 +670,7 @@ export class Activator implements ActivationHandler {
668670
const validate = composeInterceptors(
669671
this.interceptors.inbound,
670672
'validateUpdate',
671-
this.validateUpdateNextHandler.bind(this)
673+
this.validateUpdateNextHandler.bind(this, entry.validator)
672674
);
673675
validate(makeInput());
674676
}
@@ -678,7 +680,7 @@ export class Activator implements ActivationHandler {
678680
return;
679681
}
680682
this.acceptUpdate(protocolInstanceId);
681-
const execute = composeInterceptors(this.interceptors.inbound, 'handleUpdate', this.updateNextHandler.bind(this));
683+
const execute = composeInterceptors(this.interceptors.inbound, 'handleUpdate', this.updateNextHandler.bind(this, entry.handler));
682684
const { unfinishedPolicy } = entry;
683685
this.inProgressUpdates.set(updateId, { name, unfinishedPolicy, id: updateId });
684686
const res = execute(input)
@@ -697,13 +699,11 @@ export class Activator implements ActivationHandler {
697699
untrackPromise(UpdateScope.updateWithInfo(updateId, name, doUpdateImpl));
698700
}
699701

700-
protected async updateNextHandler({ name, args }: UpdateInput): Promise<unknown> {
701-
const { handler } = this.updateHandlers.get(name)!;
702+
protected async updateNextHandler(handler: WorkflowUpdateType, { args }: UpdateInput): Promise<unknown> {
702703
return await handler(...args);
703704
}
704705

705-
protected validateUpdateNextHandler({ name, args }: UpdateInput): void {
706-
const { validator } = this.updateHandlers.get(name) ?? {};
706+
protected validateUpdateNextHandler(validator: WorkflowUpdateValidatorType | undefined, { args }: UpdateInput): void {
707707
if (validator) {
708708
validator(...args);
709709
}

0 commit comments

Comments
 (0)