Skip to content
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

Return onCancel callback from the executor #55

Open
Filyus opened this issue Jun 19, 2021 · 0 comments
Open

Return onCancel callback from the executor #55

Filyus opened this issue Jun 19, 2021 · 0 comments

Comments

@Filyus
Copy link

Filyus commented Jun 19, 2021

It seems to me that instead of

executor(resolve, reject, (onCancel) => {
  internals.onCancelList.push(onCancel);
})
const promise = new CancelablePromise((resolve, reject, onCancel) => {
  onCancel(() => {
    //cancel code
  });
});

it is a bit easier to use such code

const onCancel = executor(resolve, reject);
internals.onCancelList.push(onCancel);
const promise = new CancelablePromise((resolve, reject) => {
  return () => {
    //cancel code
  };
});
@Filyus Filyus changed the title return onCancel callback from the executor Return onCancel callback from the executor Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants