inamiy/SwiftTask — pull request #2 by inamiy (2014-08-26 14:15:30+00:00)
Title: Add task.then() which can handle both fulfilled & rejected.

Current `task.then(_ closure:)` method invokes `closure` only when `task` was fulfilled,
but this is not a good idea compared to ES6-Promise's spec as decribed in
[JavaScript Promises: There and back again - HTML5 Rocks](http://www.html5rocks.com/en/tutorials/es6/promises/), i.e.

```
promise.then(onFulfilled, onRejected)
```

The reason is that we can't establish the same behavior just by chaining fulfilled-only `then` and rejected-only `catch`.

So I also implement above method in a form:

```
public func then(thenClosure: (Value?, ErrorInfo?) -> Value2) -> Task

public func then(thenClosure: (Value?, ErrorInfo?) -> Task) -> Task
```

Since `SwiftTask` heavily uses generics, it is smarter to combine `onFulfilled` and `onRejected` handlers into single `thenClosure` so that we don't have to specify long type twice.