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

Commit

Permalink
Release 0.9.2 with #11 Retry kommand or multiple kommands throwing a …
Browse files Browse the repository at this point in the history
…RecoverableError
  • Loading branch information
alexruperez committed Nov 1, 2017
1 parent 64ab7cd commit fd3a64e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 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.9.2

- [x] Retry kommand or multiple kommands throwing a [RecoverableError](https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md#new-protocols).

# Release 0.9.1

- [x] Removed DispatchWorkItem, now internally working with Operation.
Expand Down
2 changes: 1 addition & 1 deletion 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.9.1'
s.version = '0.9.2'
s.summary = 'A command pattern implementation written in Swift 4'

s.homepage = 'https://github.com/intelygenz/Kommander-iOS'
Expand Down
10 changes: 8 additions & 2 deletions Kommander.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
81DBBB331E7691F400EF01D8 /* Major watchOS.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 81DBBB181E7691F300EF01D8 /* Major watchOS.app */; };
D56F57291F7BB864005B3692 /* Kommander.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81DBBAD71E768DB300EF01D8 /* Kommander.framework */; };
D56F572A1F7BB864005B3692 /* Kommander.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 81DBBAD71E768DB300EF01D8 /* Kommander.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D5D3583B1FA9E70500F1C79B /* KommandCancelledError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DE0DE341FA380CD001FAC71 /* KommandCancelledError.swift */; };
D5D3583C1FA9E70500F1C79B /* KommandCancelledError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DE0DE341FA380CD001FAC71 /* KommandCancelledError.swift */; };
D5D3583D1FA9E70600F1C79B /* KommandCancelledError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DE0DE341FA380CD001FAC71 /* KommandCancelledError.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -784,6 +787,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D5D3583D1FA9E70600F1C79B /* KommandCancelledError.swift in Sources */,
819D15651E76AF7D00BB1F07 /* Kommander.swift in Sources */,
819D15691E76AF7D00BB1F07 /* CurrentDispatcher.swift in Sources */,
819D15661E76AF7D00BB1F07 /* Kommand.swift in Sources */,
Expand All @@ -796,6 +800,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D5D3583B1FA9E70500F1C79B /* KommandCancelledError.swift in Sources */,
81DBBB071E768EF000EF01D8 /* Kommander.swift in Sources */,
81DBBB011E768ED700EF01D8 /* CurrentDispatcher.swift in Sources */,
81DBBAFF1E768ED100EF01D8 /* Kommand.swift in Sources */,
Expand All @@ -808,6 +813,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D5D3583C1FA9E70500F1C79B /* KommandCancelledError.swift in Sources */,
81DBBB081E768EF100EF01D8 /* Kommander.swift in Sources */,
81DBBB021E768ED700EF01D8 /* CurrentDispatcher.swift in Sources */,
81DBBB001E768ED100EF01D8 /* Kommand.swift in Sources */,
Expand Down Expand Up @@ -984,7 +990,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 0.9.0;
DYLIB_CURRENT_VERSION = 0.9.1;
DYLIB_CURRENT_VERSION = 0.9.2;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -1056,7 +1062,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 0.9.0;
DYLIB_CURRENT_VERSION = 0.9.1;
DYLIB_CURRENT_VERSION = 0.9.2;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
2 changes: 2 additions & 0 deletions KommanderTests/KommanderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class KommanderTests: XCTestCase {
XCTAssertEqual(error.recoveryOptions, ["Retry the Kommand"])
let recoverySuccess = error.attemptRecovery(optionIndex: 0)
XCTAssert(recoverySuccess)
let secondRecoverySuccess = error.attemptRecovery(optionIndex: 0)
XCTAssertFalse(secondRecoverySuccess)
})
.execute()
.cancel(true, after: .seconds(2))
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Inspired on the Java library [**Kommander**](https://github.com/Wokdsem/Kommande
- [x] Make kommand or multiple kommands
- [x] Execute kommand or multiple kommands
- [x] Cancel kommand or multiple kommands
- [x] Retry kommand or multiple kommands
- [x] Set kommand success block
- [x] Set kommand error block
- [x] Main thread dispatcher
Expand Down Expand Up @@ -79,7 +80,7 @@ dependencies: [

## Usage

#### Making, executing and cancelling Kommands:
#### Making, executing, cancelling and retrying Kommands:

```swift
Kommander().makeKommand {
Expand Down Expand Up @@ -119,6 +120,8 @@ let kommand = Kommander().makeKommand { () -> Any? in
}).execute()

kommand.cancel()

kommand.retry()
```

#### Creating Kommanders:
Expand Down
8 changes: 2 additions & 6 deletions Source/Kommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ open class Kommand<Result> {
executor?.execute(after: delay, block: {
self.execute()
})

return self
}

Expand Down Expand Up @@ -123,7 +122,6 @@ open class Kommand<Result> {
executor?.execute(after: delay, block: {
self.cancel(throwingError)
})

return self
}

Expand All @@ -134,7 +132,7 @@ open class Kommand<Result> {
}
self.deliverer?.execute {
if throwingError {
self.errorBlock?(KommandCancelledError(kommand: self))
self.errorBlock?(KommandCancelledError(self))
}
}
if let operation = operation, !operation.isFinished {
Expand All @@ -149,7 +147,6 @@ open class Kommand<Result> {
executor?.execute(after: delay, block: {
self.retry()
})

return self
}

Expand All @@ -159,8 +156,7 @@ open class Kommand<Result> {
return self
}
state = .ready
execute()
return self
return execute()
}

}
5 changes: 4 additions & 1 deletion Source/KommandCancelledError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct KommandCancelledError<Result>: RecoverableError {

private let kommand: Kommand<Result>

init(kommand: Kommand<Result>) {
init(_ kommand: Kommand<Result>) {
self.kommand = kommand
}

Expand All @@ -21,6 +21,9 @@ public struct KommandCancelledError<Result>: RecoverableError {
}

public func attemptRecovery(optionIndex recoveryOptionIndex: Int) -> Bool {
guard kommand.state == .canceled else {

This comment has been minimized.

Copy link
@juantrias

juantrias Nov 2, 2017

Contributor

Good point 👍

return false
}
kommand.retry()
return true
}
Expand Down

0 comments on commit fd3a64e

Please sign in to comment.