https://github.com/orta/ar_dispatch
Dispatch functions run async code synchronous in tests
https://github.com/orta/ar_dispatch
Last synced: about 1 year ago
JSON representation
Dispatch functions run async code synchronous in tests
- Host: GitHub
- URL: https://github.com/orta/ar_dispatch
- Owner: orta
- License: mit
- Created: 2014-12-04T11:49:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T13:47:02.000Z (over 3 years ago)
- Last Synced: 2025-05-01T10:12:15.867Z (about 1 year ago)
- Language: Objective-C
- Size: 249 KB
- Stars: 25
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ar_dispatch
Make the Foundation dispatch_xxx_ functions run normally async code synchronously in tests
[](https://travis-ci.org/Orta Therox/ar_dispatch)
[](http://cocoadocs.org/docsets/ar_dispatch)
[](http://cocoadocs.org/docsets/ar_dispatch)
[](http://cocoadocs.org/docsets/ar_dispatch)
## What is does
Adds a collection of methods around the dispatch queue that will run synchronously when being ran in a test target, but will act asynchronously in application targets. Tested.
``` objc
/// Async in App Code, sync in Test Code, waits for a time then runs the block on the main queue
extern void ar_dispatch_after(NSTimeInterval time, dispatch_block_t block);
/// Async in App Code, sync in Test Code, waits for a time then runs the block on your own queue
extern void ar_dispatch_after_on_queue(NSTimeInterval time, dispatch_queue_t queue, dispatch_block_t block);
/// Async in App Code, sync in Test Code, runs a block on a default queue on another thread
extern void ar_dispatch_async(dispatch_block_t block);
/// Async in App Code, sync in Test Code, runs a block on the main thread
extern void ar_dispatch_main_queue(dispatch_block_t block);
/// Async in App Code, sync in Test Code, runs block on a queue
extern void ar_dispatch_on_queue(dispatch_queue_t queue, dispatch_block_t block);
```
## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Installation
ar_dispatch is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
pod "ar_dispatch"
## Author
Orta Therox, orta.therox@gmail.com
## License
ar_dispatch is available under the MIT license. See the LICENSE file for more info.