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

Replace .linkCancel with automatic tracking #3

Closed
lilyball opened this issue Jan 15, 2018 · 2 comments
Closed

Replace .linkCancel with automatic tracking #3

lilyball opened this issue Jan 15, 2018 · 2 comments
Assignees
Milestone

Comments

@lilyball
Copy link
Owner

lilyball commented Jan 15, 2018

If we double-box the Promise, we can track when any given Promise is no longer capable of having new observers attached or its result property ready. At this point, if all attached observers have cancelled, we can go ahead and cancel the parent promise.

With this scheme we can remove .linkCancel entirely as it will just happen automatically. It's slightly less flexible, as I cannot create a second observer on a promise without affecting cancellation behavior, but it's worth it for the simplified API.

Note: If a new Promise becomes unobservable without having any observers attached to begin with, we will not automatically cancel it. This behavior would be surprising, in the event that the promise has observable side-effects.

@lilyball lilyball added the TODO label Jan 15, 2018
@lilyball lilyball added this to the v0.2 milestone Jan 15, 2018
This was referenced Jan 15, 2018
@lilyball
Copy link
Owner Author

When bridging between Swift↔Obj-C we should just behave like .linkCancel (which is what we do today). We can't do normal cancel propagation because the Swift bridging code can't see Obj-C private stuff. But that's ok because the bridged promise is supposed to be a stand-in for the original promise, which means cancelling the bridged promise should go ahead and immediate cancel the original promise even if there are other observers attached to it.

@lilyball lilyball self-assigned this Jan 17, 2018
@lilyball
Copy link
Owner Author

Fixed in 6c947cc.

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

1 participant