SwiftCoroutine_Utils
Some useful extensions for SwiftCoroutine library https://github.com/belozierov/SwiftCoroutine
Installation
Cocoapods
pod 'SwiftCoroutine_Utils'
or:
pod 'SwiftCoroutine_Utils/OperationQueue'
pod 'SwiftCoroutine_Utils/CoFuture'
Concept
Add some methods for CoFuture and OperationQueue like:
public extension CoFuture {
func whenComplete(_ callback: @escaping (Result<Value, Error>) -> Void, on queue: DispatchQueue)
func whenSuccess(_ callback: @escaping (Value) -> Void, on queue: DispatchQueue)
func whenFailure(_ callback: @escaping (Error) -> Void, on queue: DispatchQueue)
func whenCanceled(_ callback: @escaping () -> Void, on queue: DispatchQueue)
func whenComplete(_ callback: @escaping () -> Void, on queue: DispatchQueue)
}
public extension OperationQueue {
func addCoOperation(_ task: @escaping (() -> CoFuture<Void>)) -> CoFuture<Void>
func addCoResultOperation<T>(_ task: @escaping (() -> CoFuture<T>)) -> CoFuture<T>
func addCoResultOperation<T>(_ task: @escaping (() -> CoFuture<T?>)) -> CoFuture<T?>
}
Usage
See Demo/SwiftCoroutine_Utils_Demo/ViewController.swift
Author
- Siarhei Ladzeika [email protected]
LICENSE
See LICENSE