Async.legacy
Async.legacy copied to clipboard
GCD chained arguments and returns take2
@chriseidhof
I've got strongly typed chained calls with arguments and return types working without any damage to the existing original API. (https://github.com/duemunk/Async/issues/8)
Surprisingly (or maybe not to you) the someChainableAsyncObject.cancel() still works passing the correct type () into the function.
func cancel(withValue:ReturnType) {
isCancelled = true
returnedValueOpt = withValue
}
By forcing the setting of the return on cancel it ensures that there is a non-Optional value to wait on (unless the block's type was optional to start with) and the chain can continue.
It needs more syntactic sugar on the new API features (Beta 6 doesn't seem to like the closure after the call syntax for these flexibly typed closures) and arguments are required on AsyncPlus calls even if it is (). It also needs more tests, a cleanup and I need to think about the effect on the drop in replacement nature of this for the main Async library but I'm happy I've got this far.
@chriseidhof @duemunk
Any views on this code. I think it fully works in terms of chaining arguments but I don't know how easy it would be to port back to the original Async version. If I do merge it then the original Async will no longer be a drop in replacement. It could probably do with more tests but I keep not getting round to it.
It's a bit too much code to quickly look at, hopefully I'll have some more time soon, but quite busy at the moment, sorry!
@josephlord Have you made any progress on this?
It works but The test coverage isn't very good. Having cracked the problem my interest level dropped.