https://github.com/inloop/inlasyncoperation
The wrapper for the AsynchronousOperation
https://github.com/inloop/inlasyncoperation
Last synced: 5 months ago
JSON representation
The wrapper for the AsynchronousOperation
- Host: GitHub
- URL: https://github.com/inloop/inlasyncoperation
- Owner: inloop
- License: mit
- Created: 2018-01-18T09:13:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-18T11:07:30.000Z (about 8 years ago)
- Last Synced: 2024-12-29T05:26:21.873Z (about 1 year ago)
- Language: Shell
- Size: 24.4 KB
- Stars: 1
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# INLAsyncOperation
## Requirements
* iOS 9.0+
## Installation
INLAsyncOperation is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'INLAsyncOperation'
```
## Usage
1. run `pod install` in your repository
2. `import INLAsyncOperation`
3. Subclass `AsynchronousOperation`
4. Override `main()`
5. Put your task implementation in `main()` of your custom class
See the example `INLAsyncOperationExample` as a reference.
```swift
struct OperationDispatcher {
private let queue = OperationQueue()
func dispatch(_ operation: Operation) {
queue.addOperation(operation)
}
}
final class SampleOperation: AsynchronousOperation {
typealias CompletionClosure = (_ emojis: [String]) -> Void
private let completion: CompletionClosure
init(completion: @escaping CompletionClosure) {
self.completion = completion
}
override func main() {
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
let array = [String](repeating: "🎉", count: 100)
self.completion(array)
}
}
}
```
## Author
radimhalfar, radim.halfar@inloop.eu
## License
INLAsyncOperation is available under the MIT license. See the LICENSE file for more info.