diff --git a/Kommander.xcodeproj/project.pbxproj b/Kommander.xcodeproj/project.pbxproj index 8ced8b9..a54d702 100644 --- a/Kommander.xcodeproj/project.pbxproj +++ b/Kommander.xcodeproj/project.pbxproj @@ -349,7 +349,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3VW789WSMP; DYLIB_COMPATIBILITY_VERSION = 0.2.0; - DYLIB_CURRENT_VERSION = 0.2.2; + DYLIB_CURRENT_VERSION = 0.2.3; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Kommander/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -370,7 +370,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3VW789WSMP; DYLIB_COMPATIBILITY_VERSION = 0.2.0; - DYLIB_CURRENT_VERSION = 0.2.2; + DYLIB_CURRENT_VERSION = 0.2.3; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Kommander/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; diff --git a/Kommander/Info.plist b/Kommander/Info.plist index 30854b5..0865cde 100644 --- a/Kommander/Info.plist +++ b/Kommander/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.2.2 + 0.2.3 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Kommander/Kommand.swift b/Kommander/Kommand.swift index 0e7f732..a22248e 100644 --- a/Kommander/Kommand.swift +++ b/Kommander/Kommand.swift @@ -10,9 +10,9 @@ import Foundation open class Kommand { - public typealias ActionBlock = () throws -> T - public typealias SuccessBlock = (_ result: T) -> Void - public typealias ErrorBlock = (_ error: Error) -> Void + public typealias ActionBlock = () throws -> T? + public typealias SuccessBlock = (_ result: T?) -> Void + public typealias ErrorBlock = (_ error: Error?) -> Void private final let deliverer: Dispatcher private final let executor: Dispatcher @@ -37,7 +37,7 @@ open class Kommand { return self } - open func execute() { + open func execute() -> Self { action = executor.execute { do { let result = try self.actionBlock() @@ -50,6 +50,7 @@ open class Kommand { } } } + return self } open func cancel() { diff --git a/Kommander/Kommander.swift b/Kommander/Kommander.swift index 8308b94..901bf45 100644 --- a/Kommander/Kommander.swift +++ b/Kommander/Kommander.swift @@ -48,11 +48,11 @@ open class Kommander { executor = Dispatcher(label: name, qos: qos, attributes: attributes, autoreleaseFrequency: autoreleaseFrequency, target: target) } - open func makeKommand(_ actionBlock: @escaping () throws -> T) -> Kommand { + open func makeKommand(_ actionBlock: @escaping () throws -> T?) -> Kommand { return Kommand(deliverer: deliverer, executor: executor, actionBlock: actionBlock) } - open func makeKommands(_ actionBlocks: [() throws -> T]) -> [Kommand] { + open func makeKommands(_ actionBlocks: [() throws -> T?]) -> [Kommand] { var kommands = [Kommand]() for actionBlock in actionBlocks { kommands.append(Kommand(deliverer: deliverer, executor: executor, actionBlock: actionBlock)) diff --git a/README.md b/README.md index 53f6d83..bc29715 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,12 @@ [![Platform](https://img.shields.io/cocoapods/p/Kommander.svg?style=flat)](http://cocoapods.org/pods/Kommander) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + **Kommander** is a Swift library to manage the task execution in different threads. Through the definition a simple but powerful concept, [**Kommand**](https://en.wikipedia.org/wiki/Command_pattern). +Inspired on the Java library [**Kommander**](https://github.com/Wokdsem/Kommander) from [**Wokdsem**](https://github.com/Wokdsem). + + ![Kommander](https://raw.githubusercontent.com/intelygenz/Kommander-iOS/master/Kommander.png) ## Features @@ -17,8 +21,8 @@ - [x] Cancel kommand or multiple kommands - [x] Set kommand success block - [x] Set kommand error block -- [x] Main threat dispatcher -- [x] Current threat dispatcher +- [x] Main thread dispatcher +- [x] Current thread dispatcher - [x] Custom OperationQueue dispatcher - [x] Custom DispatchQueue dispatcher - [x] Execute single or multiple Operation @@ -39,13 +43,13 @@ pod 'Kommander' For Swift 2 compatibility use: ```ruby -pod 'Kommander', :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => '0.2.2-swift2' +pod 'Kommander', :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => '0.2.3-swift2' ``` For Objective-C compatibility use: ```ruby -pod 'Kommander', :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => '0.2.2-objc' +pod 'Kommander', :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => '0.2.3-objc' ``` #### Or you can install it with [Carthage](https://github.com/Carthage/Carthage): @@ -77,12 +81,12 @@ Kommander().makeKommand { () -> Void in ## Authors -'Juan TrĂ­as' => 'juan.trias@intelygenz.com', 'Roberto Estrada' => 'roberto.estrada@intelygenz.com' - [alexruperez](https://github.com/alexruperez), alejandro.ruperez@intelygenz.com + [juantrias](https://github.com/juantrias), juan.trias@intelygenz.com -[RobertoEstrada](https://github.com/RobertoEstrada), roberto.estrada@intelygenz.com' + +[RobertoEstrada](https://github.com/RobertoEstrada), roberto.estrada@intelygenz.com ## License -Kommander is available under the MIT license. See the LICENSE file for more info. +Kommander is available under the MIT license. See the LICENSE file for more info. \ No newline at end of file