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

Commit

Permalink
Release 0.6.1 with @discardableResult
Browse files Browse the repository at this point in the history
  • Loading branch information
alexruperez committed Apr 28, 2017
1 parent 9592761 commit deff54a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 0.6.1

- [x] @discardableResult

# Release 0.6.0

- [x] Execute and cancel after delay
Expand Down
3 changes: 1 addition & 2 deletions Kommander.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Kommander'
s.version = '0.6.0'
s.version = '0.6.1'
s.summary = 'A command pattern implementation written in Swift 3'

s.homepage = 'https://github.com/intelygenz/Kommander-iOS'
Expand All @@ -16,4 +16,3 @@ Pod::Spec.new do |s|

s.source_files ="Source/*.{h,swift}"
end

4 changes: 2 additions & 2 deletions Kommander.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 0.6.0;
DYLIB_CURRENT_VERSION = 0.6.0;
DYLIB_CURRENT_VERSION = 0.6.1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -1036,7 +1036,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 0.6.0;
DYLIB_CURRENT_VERSION = 0.6.0;
DYLIB_CURRENT_VERSION = 0.6.1;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
8 changes: 4 additions & 4 deletions KommanderTests/KommanderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class KommanderTests: XCTestCase {

let ex = expectation(description: String(describing: type(of: self)))

_ = interactor.getCounter(name: "C1", to: 3)
interactor.getCounter(name: "C1", to: 3)
.onSuccess({ (name) in
ex.fulfill()
})
Expand Down Expand Up @@ -68,8 +68,8 @@ class KommanderTests: XCTestCase {
XCTFail()
}).execute()

_ = k1.execute()
_ = k2.execute()
k1.execute()
k2.execute()

waitForExpectations(timeout: 100, handler: nil)
}
Expand All @@ -82,7 +82,7 @@ class KommanderTests: XCTestCase {
let calls = Int(arc4random_uniform(10) + 1)

for i in 0..<calls {
_ = interactor.getCounter(name: "C\(i)", to: 3)
interactor.getCounter(name: "C\(i)", to: 3)
.onSuccess({ (name) in
successes+=1
if successes>=calls {
Expand Down
6 changes: 3 additions & 3 deletions Major/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ViewController: UIViewController {
let sleepTime: UInt32 = 2

@IBAction func singleAction(_ sender: UIButton) {
_ = kommander.makeKommand { () -> TimeInterval in
kommander.makeKommand { () -> TimeInterval in
sleep(self.sleepTime)
return Date().timeIntervalSince1970
}.onSuccess { result in
Expand Down Expand Up @@ -56,7 +56,7 @@ class ViewController: UIViewController {
}

@IBAction func errorAction(_ sender: UIButton) {
_ = kommander.makeKommand {
kommander.makeKommand {
sleep(self.sleepTime)
throw CocoaError(.featureUnsupported)
}.onError { error in
Expand All @@ -65,7 +65,7 @@ class ViewController: UIViewController {
}

@IBAction func crashAction(_ sender: UIButton) {
_ = kommander.makeKommand {
kommander.makeKommand {
sleep(self.sleepTime)
fatalError()
}.execute()
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ dependencies: [
## Usage

```swift
_ = Kommander().makeKommand {
Kommander().makeKommand {
// Your code here
}.execute()
```

```swift
_ = Kommander().makeKommand { () -> String in
Kommander().makeKommand { () -> String in
return "Your string"
}.onSuccess { yourString in
print(yourString)
}.execute()
```

```swift
_ = Kommander().makeKommand {
Kommander().makeKommand {
throw CocoaError(.featureUnsupported)
}.onError({ error in
print(String(describing: error!))
Expand Down
6 changes: 3 additions & 3 deletions Source/Dispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ open class Dispatcher {
}

/// Execute block in priority queue
open func execute(_ block: @escaping () -> Void) -> Any {
@discardableResult open func execute(_ block: @escaping () -> Void) -> Any {
if priority == .dispatch {
return execute(qos: nil, flags: nil, block: block)
}
Expand All @@ -82,7 +82,7 @@ open class Dispatcher {
}

/// Execute [block] collection in priority queue (if possible) concurrently or sequentially
open func execute(_ blocks: [() -> Void], concurrent: Bool = true, waitUntilFinished: Bool = false) -> [Any] {
@discardableResult open func execute(_ blocks: [() -> Void], concurrent: Bool = true, waitUntilFinished: Bool = false) -> [Any] {
var lastOperation: Operation?
let operations = blocks.map { block -> Operation in
let blockOperation = BlockOperation(block: block)
Expand Down Expand Up @@ -112,7 +112,7 @@ open class Dispatcher {
}

/// Execute block in DispatchQueue using custom DispatchWorkItem instance
open func execute(qos: DispatchQoS?, flags: DispatchWorkItemFlags?, block: @escaping @convention(block) () -> ()) -> DispatchWorkItem {
@discardableResult open func execute(qos: DispatchQoS?, flags: DispatchWorkItemFlags?, block: @escaping @convention(block) () -> ()) -> DispatchWorkItem {
let work = DispatchWorkItem(qos: qos ?? .default, flags: flags ?? .assignCurrentContext, block: block)
execute(work)
return work
Expand Down
18 changes: 9 additions & 9 deletions Source/Kommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ open class Kommand<Result> {
}

/// Specify Kommand<Result> success block
open func onSuccess(_ onSuccess: @escaping SuccessBlock) -> Self {
@discardableResult open func onSuccess(_ onSuccess: @escaping SuccessBlock) -> Self {
self.successBlock = onSuccess
return self
}

/// Specify Kommand<Result> error block
open func onError(_ onError: @escaping ErrorBlock) -> Self {
@discardableResult open func onError(_ onError: @escaping ErrorBlock) -> Self {
self.errorBlock = onError
return self
}

/// Execute Kommand<Result> after delay
open func execute(after delay: TimeInterval) -> Self {
@discardableResult open func execute(after delay: TimeInterval) -> Self {
executor?.execute(after: delay, block: {
_ = self.execute()
self.execute()
})

return self
}

/// Execute Kommand<Result>
open func execute() -> Self {
@discardableResult open func execute() -> Self {
guard state == .ready else {
return self
}
Expand All @@ -103,7 +103,7 @@ open class Kommand<Result> {
guard self.state == .running else {
return
}
_ = self.deliverer?.execute {
self.deliverer?.execute {
self.state = .finished
self.successBlock?(result)
}
Expand All @@ -112,7 +112,7 @@ open class Kommand<Result> {
guard self.state == .running else {
return
}
_ = self.deliverer?.execute {
self.deliverer?.execute {
self.state = .finished
self.errorBlock?(error)
}
Expand All @@ -130,7 +130,7 @@ open class Kommand<Result> {
/// Cancel Kommand<Result> after delay
open func cancel(_ throwingError: Bool = false, after delay: TimeInterval) {
executor?.execute(after: delay, block: {
_ = self.cancel(throwingError)
self.cancel(throwingError)
})
}

Expand All @@ -139,7 +139,7 @@ open class Kommand<Result> {
guard state != .canceled else {
return
}
_ = self.deliverer?.execute {
self.deliverer?.execute {
if throwingError {
self.errorBlock?(CocoaError(.userCancelled))
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Kommander.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ open class Kommander {
guard kommand.state == .running else {
return
}
_ = self.deliverer.execute {
self.deliverer.execute {
kommand.state = .finished
kommand.successBlock?(result)
}
Expand All @@ -118,7 +118,7 @@ open class Kommander {
guard kommand.state == .running else {
return
}
_ = self.deliverer.execute {
self.deliverer.execute {
kommand.state = .finished
kommand.errorBlock?(error)
}
Expand Down

0 comments on commit deff54a

Please sign in to comment.