Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Updates docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vittoriom committed Oct 15, 2016
1 parent 0e8b6e1 commit 1adee26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 0.9

**Breaking changes**
- `PiedPiper` is now compiled with Swift 2.3
- `merge` has been deprecated, please use `mergeAll` instead

**New features**
- Added `mergeSome` to a `SequenceType` of `Future`s to collapse a list of `Future`s into a single one that succeeds even if some of the `Future`s fail (contrast to `merge`)
- Added `all` to a `SequenceType` of `Future`s to collapse a list of `Future`s into a single one that succeeds when all of the elements of the sequence succeed, and fails when one of the element fails (it's similar to `merge` but it doesn't bring the results with it).
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ queue.async { Void -> Int in

### Advanced usage with Futures

Since `Pied Piper 0.8` many convenience functions are available on `Future` values, like `map`, `flatMap`, `filter`, `recover`, `zip`, `reduce` and `merge`. Moreover, `traverse` is available for all `SequenceType` values.
Since `Pied Piper 0.8` many convenience functions are available on `Future` values, like `map`, `flatMap`, `filter`, `recover`, `zip`, `reduce`, `mergeSome` and `mergeAll`. Moreover, `traverse` is available for all `SequenceType` values.

Since `Pied Piper 0.9` some more functions are available like `snooze`, `timeout` and `firstCompleted` (the latter for a `SequenceType` of `Future` values).

Expand Down Expand Up @@ -302,29 +302,29 @@ let sumOfServerResults = serverRequests.reduce(0, combine: +).onSuccess {
}
```

#### Merge
#### MergeAll

```swift
// Let's assume this value contains a list of server requests where each request obtains the number of items in a given category
let serverRequests: [Future<Int>] = doFoo()

// With this `merge` call we collapse the requests into one containing the result of all of them, if they all succeeded, or none if one fails
let allServerResults = serverRequests.merge().onSuccess { results in
// With this `mergeAll` call we collapse the requests into one containing the result of all of them, if they all succeeded, or none if one fails
let allServerResults = serverRequests.mergeAll().onSuccess { results in
// We get here only if all futures succeed
// `results` is an [Int]
}
```

#### All

`all` behaves exactly like `merge`, except that it doesn't bring the success values with it.
`all` behaves exactly like `mergeAll`, except that it doesn't bring the success values with it.

```swift
// Let's assume this value contains a list of server requests where each request obtains the number of items in a given category
let serverRequests: [Future<Int>] = doFoo()

// With this `all` call we collapse the requests into one that will succeed if all of the elements succeed, otherwise it will fail
let allServerResults = serverRequests.merge().onSuccess {
let allServerResults = serverRequests.mergeAll().onSuccess {
// We get here only if all futures succeed
}
```
Expand All @@ -335,7 +335,7 @@ let allServerResults = serverRequests.merge().onSuccess {
// Let's assume this value contains a list of server requests where each request obtains the number of items in a given category
let serverRequests: [Future<Int>] = doFoo()

// With this `merge` call we collapse the requests into one containing the result of just the ones that succeed
// With this `mergeSome` call we collapse the requests into one containing the result of just the ones that succeed
let allServerResults = serverRequests.mergeSome().onSuccess { results in
// We get here and results.count == the number of succeeded requests
// `results` is an [Int]
Expand Down

0 comments on commit 1adee26

Please sign in to comment.