Skip to main content

How to handle a Signal in TypeScript

setHandler

import { setHandler } from '@temporalio/workflow';

export async function yourWorkflow() {
const groups = new Map<string, Set<string>>();

setHandler(joinSignal, ({ userId, groupId }: JoinInput) => {
const group = groups.get(groupId);
if (group) {
group.add(userId);
} else {
groups.set(groupId, new Set([userId]));
}
});
}