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

A way to hold onto a promise without blocking cancellation propagation from children #46

Closed
lilyball opened this issue Nov 25, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@lilyball
Copy link
Owner

I want to be able to hold onto a promise such that I can create new children, without blocking cancellation propagation from any existing children. With such a mechanism, I should have a callback that's invoked as soon as all children have requested cancel, so I can throw away the parent promise I'm holding.

The idea here is so I can dedupe requests for an upstream asynchronous resource (such as loading images from the network), and allow for cancelling the upstream asynchronous resource as soon as all children have declared they're no longer interested in it.

@lilyball lilyball added the enhancement New feature or request label Nov 25, 2019
@lilyball
Copy link
Owner Author

The actual implementation here is basically just returning a pre-sealed promise, but we need to do this as a child so we have access to the onRequestCancel callback as being able to drop the promise at the point where cancellation is propagated from children upwards is important.

@lilyball
Copy link
Owner Author

Or we could actually just seal the receiver and attach a new onCancelRequested callback to the resolver. I'm not terribly fond of this because that will pipe cancellation upwards prior to calling the new callback, which means we could end up in a situation where our new onCancelRequested callback is invoked after an onCancel callback (if cancellation is handled upstream as .immediate and onCancel is also .immediate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant