Async.legacy icon indicating copy to clipboard operation
Async.legacy copied to clipboard

GCD chained arguments and returns take2

Open josephlord opened this issue 11 years ago • 4 comments

@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.

josephlord avatar Sep 02 '14 01:09 josephlord

@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.

josephlord avatar Sep 27 '14 23:09 josephlord

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!

chriseidhof avatar Sep 29 '14 07:09 chriseidhof

@josephlord Have you made any progress on this?

duemunk avatar Jan 05 '15 09:01 duemunk

It works but The test coverage isn't very good. Having cracked the problem my interest level dropped.

josephlord avatar Jan 05 '15 10:01 josephlord