Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(workflow)!: Rename setListener to setHandler #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2021
Merged

Conversation

bergundy
Copy link
Member

@bergundy bergundy commented Nov 1, 2021

BREAKING CHANGE: The function's usage remains the same, only the name
was changed.

Before:

import { defineSignal, setListener, condition } from '@temporalio/workflow';
import { unblockSignal } from './definitions';

export const unblockSignal = defineSignal('unblock');

export async function myWorkflow() {
  let isBlocked = true;
  setListener(unblockSignal, () => void (isBlocked = false));
  await condition(() => !isBlocked);
}

After:

import { defineSignal, setHandler, condition } from '@temporalio/workflow';
import { unblockSignal } from './definitions';

export const unblockSignal = defineSignal('unblock');

export async function myWorkflow() {
  let isBlocked = true;
  setHandler(unblockSignal, () => void (isBlocked = false));
  await condition(() => !isBlocked);
}

Reasoning:

  • It was our go-to name initially but we decided against it when to avoid confusion with the WorkflowHandle concept
  • Handling seems more accurate about what the function is doing than listening
  • With listeners it sounds like you can set multiple listeners, and handler doesn't

BREAKING CHANGE: The function's usage remains the same, only the name
was changed.

Before:
```ts
import { defineSignal, setListener, condition } from '@temporalio/workflow';
import { unblockSignal } from './definitions';

export const unblockSignal = defineSignal('unblock');

export async function myWorkflow() {
  let isBlocked = true;
  setListener(unblockSignal, () => void (isBlocked = false));
  await condition(() => !isBlocked);
}
```

After:
```ts
import { defineSignal, setHandler, condition } from '@temporalio/workflow';
import { unblockSignal } from './definitions';

export const unblockSignal = defineSignal('unblock');

export async function myWorkflow() {
  let isBlocked = true;
  setHandler(unblockSignal, () => void (isBlocked = false));
  await condition(() => !isBlocked);
}
```
@bergundy bergundy requested a review from swyxio November 1, 2021 21:05
@bergundy bergundy self-assigned this Nov 1, 2021
@bergundy bergundy added this to the beta milestone Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants