Skip to content

Add Canceller for removing progress/then handlers. #31

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 6 commits into from
May 10, 2015

Conversation

inamiy
Copy link
Member

@inamiy inamiy commented May 8, 2015

(JavaScript) Promise is normally designed to only attach then-handlers to preceding task, but it often lacks in those removability, especially when user wants to remove them one-by-one.
(Promise usually removeAll() when it is deallocated)

This kind of casual & rough monad structure is not an issue when only dealing with a single future value, but when multiple progressing values come in, without a support of one-by-one invalidation, it will degrade efficiency of multiple task collaboration, i.e. ReactKit.

This pull request will add one-by-one invalidation of progress/then handlers by using Canceller.
Unlike publish-subscribe-model which normally returns disposable token as returning value,
I decided to use inout parameter to maintain Promise pipelining.

Usage

let task = ...
var canceller: Canceller? = nil

task.progress(&canceller) { ... }.then { ... }

// at some point before `task` completes
canceller?.cancel()   // removes progressHandler

@inamiy inamiy force-pushed the feature/removable-handler branch from c9229d3 to 907008a Compare May 9, 2015 16:13
@inamiy inamiy changed the title [WIP] Add removeProgress() & removeThen() [WIP] Add Canceller for removing progress/then handlers. May 9, 2015
@inamiy inamiy changed the title [WIP] Add Canceller for removing progress/then handlers. Add Canceller for removing progress/then handlers. May 10, 2015
@inamiy inamiy added this to the 3.1.0 milestone May 10, 2015
@inamiy
Copy link
Member Author

inamiy commented May 10, 2015

:shipit:

inamiy added a commit that referenced this pull request May 10, 2015
Add Canceller for removing progress/then handlers.
@inamiy inamiy merged commit cd9d110 into master May 10, 2015
@inamiy inamiy deleted the feature/removable-handler branch May 10, 2015 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant