Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
vmartinelli committed Nov 7, 2015
1 parent 9b231ca commit 3313977
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -212,12 +212,12 @@ Only failable tasks can be cancelled.

#### The main thread

Even if you cannot "await" a task on main thread, you still can start a background task from the main thread. If you want to handle its completion you can use `TaskWaiter` helper class. If the queue parameter is not added, the callback closure will be called on the main thread.
Even if you cannot "await" a task on main thread, you still can start a background task from the main thread. If you want to handle its completion you may use `TaskWaiter` helper class. If the queue parameter is not added, the callback closures will be called on the main thread.

```swift
// this code is running on the main thread
TaskWaiter(task: asyncCalculate())
.didFinishWithValue { vaue in
.didFinishWithValue { value in
print("The result is \(value)")
}
.didFinishWithError { error in
Expand All @@ -227,7 +227,7 @@ TaskWaiter(task: asyncCalculate())
print("Task was cancelled")
}
.didFinish { task in
// this closure will be called always even if a task was cancelled
// this closure will be always called, even if the task was cancelled

if let error = error where !error.userCancelled {
// do a nice error handling here
Expand Down Expand Up @@ -257,7 +257,7 @@ func asyncCalculate() -> Task<Int> {
}
```

The difference between a failable task and a non-failable task is that a non-failable does not have the `didFinishWithError` nor `didCancel` methods.
The difference between a failable task and a non-failable task is that a non-failable task waiter is called `NonFailableTaskWaiter` and it does not have the `didFinishWithError` nor `didCancel` methods.

### Considerations

Expand Down

0 comments on commit 3313977

Please sign in to comment.