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

Passing cancellation reason to cancel handler #17

Closed
BendingBender opened this issue Mar 6, 2019 · 5 comments
Closed

Passing cancellation reason to cancel handler #17

BendingBender opened this issue Mar 6, 2019 · 5 comments

Comments

@BendingBender
Copy link
Contributor

BendingBender commented Mar 6, 2019

Does it make sense to pass the cancellation reason to the registered cancel handlers, like this:

const promise = new PCancelable((resolve, reject, onCancel) => {
    onCancel(reason => {
        console.log(reason); // <= should print 'foo'
    });
});

promise.cancel('foo');

If it does, I'll make a PR.

@BendingBender BendingBender changed the title Passing cancellation reson to cancel handler Passing cancellation reason to cancel handler Mar 6, 2019
@sindresorhus
Copy link
Owner

Do you have any use-case in mind? I don't see why not to add it, but I also don't see what it could be useful for.

@BendingBender
Copy link
Contributor Author

Not really a use case, I just saw it was a low-hanging fruit. It kind of opens a bi-directional channel between the promise provider and consumer.

@sindresorhus
Copy link
Owner

// @bfred-it @szmarczak Thoughts?

@fregante
Copy link
Contributor

fregante commented Mar 16, 2019

In 2 years nobody actually needed this, so unless there's real interest maybe it shouldn't be implemented "just in case". Either way, 🤷‍♂️

@szmarczak
Copy link
Contributor

I agree with @bfred-it. I don't see any use case either.

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

No branches or pull requests

4 participants