Skip to content

Commit

Permalink
Merge branch 'master' of github.com:BoltsFramework/Bolts-iOS
Browse files Browse the repository at this point in the history
Conflicts:
	Readme.md
  • Loading branch information
David Poll committed Apr 30, 2014
2 parents f4eb5ed + e37415c commit f7f65de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.

## Coding Style
* Most importantly, match the exiting code style as much as possible.
* Most importantly, match the existing code style as much as possible.
* Try to keep lines under 100 characters, if possible.

## License
Expand Down
28 changes: 27 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,32 @@ For common cases, such as dispatching on the main thread, we have provided defau
}];
```

## Task Cancellation

It's generally bad design to keep track of the `BFTaskCompletionSource` for cancellation. A better model is to create a "cancellation token" at the top level, and pass that to each async function that you want to be part of the same "cancelable operation". Then, in your continuation blocks, you can check whether the cancellation token has been cancelled and bail out early by returning a `[BFTask cancelledTask]`. For example:

```objective-c
- (void)doSomethingComplicatedAsync:(MYCancellationToken *)cancellationToken {
[[self doSomethingAsync:cancellationToken] continueWithBlock:^{
if (cancellationToken.isCancelled) {
return [BFTask cancelledTask];
}
// Do something that takes a while.
return result;
}];
}

// Somewhere else.
MYCancellationToken *cancellationToken = [[MYCancellationToken alloc] init];
[obj doSomethingComplicatedAsync:cancellationToken];

// When you get bored...
[cancellationToken cancel];
```
**Note:** The cancellation token implementation should be thread-safe.
We are likely to add some concept like this to Bolts at some point in the future.
# App Links
[App Links](http://www.applinks.org) provide a cross-platform mechanism that allows a developer to define and publish a deep-linking scheme for their content, allowing other apps to link directly to an experience optimized for the device they are running on. Whether you are building an app that receives incoming links or one that may link out to other apps' content, Bolts provides tools to simplify implementation of the [App Links protocol](http://www.applinks.org/documentation).
Expand Down Expand Up @@ -395,4 +421,4 @@ You can download the latest framework files from our [Releases page](https://git

Bolts is also available through [CocoaPods](http://cocoapods.org). To install it simply add the following line to your Podfile:

pod "Bolts"
pod 'Bolts'

0 comments on commit f7f65de

Please sign in to comment.