Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
Release 0.2.3.
Browse files Browse the repository at this point in the history
Returning Kommand on execute.
Optional result and error.
  • Loading branch information
Alex Rupérez committed Feb 27, 2017
2 parents 90146ac + 6dcaaab commit d9e68ad
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Kommander.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Kommander/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.2.2</string>
<string>0.2.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 5 additions & 4 deletions Kommander/Kommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Foundation

open class Kommand<T> {

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
Expand All @@ -37,7 +37,7 @@ open class Kommand<T> {
return self
}

open func execute() {
open func execute() -> Self {
action = executor.execute {
do {
let result = try self.actionBlock()
Expand All @@ -50,6 +50,7 @@ open class Kommand<T> {
}
}
}
return self
}

open func cancel() {
Expand Down
4 changes: 2 additions & 2 deletions Kommander/Kommander.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ open class Kommander {
executor = Dispatcher(label: name, qos: qos, attributes: attributes, autoreleaseFrequency: autoreleaseFrequency, target: target)
}

open func makeKommand<T>(_ actionBlock: @escaping () throws -> T) -> Kommand<T> {
open func makeKommand<T>(_ actionBlock: @escaping () throws -> T?) -> Kommand<T> {
return Kommand<T>(deliverer: deliverer, executor: executor, actionBlock: actionBlock)
}

open func makeKommands<T>(_ actionBlocks: [() throws -> T]) -> [Kommand<T>] {
open func makeKommands<T>(_ actionBlocks: [() throws -> T?]) -> [Kommand<T>] {
var kommands = [Kommand<T>]()
for actionBlock in actionBlocks {
kommands.append(Kommand<T>(deliverer: deliverer, executor: executor, actionBlock: actionBlock))
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -77,12 +81,12 @@ Kommander().makeKommand { () -> Void in

## Authors

'Juan Trías' => '[email protected]', 'Roberto Estrada' => '[email protected]'

[alexruperez](https://github.com/alexruperez), [email protected]

[juantrias](https://github.com/juantrias), [email protected]
[RobertoEstrada](https://github.com/RobertoEstrada), [email protected]'

[RobertoEstrada](https://github.com/RobertoEstrada), [email protected]

## 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.

0 comments on commit d9e68ad

Please sign in to comment.