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

Commit

Permalink
public -> open for subclassing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Rupérez committed Feb 22, 2017
1 parent dc1b5d7 commit 64ec60f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions Kommander.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'Kommander'
s.version = '0.2.0'
s.version = '0.2.1'
s.summary = 'A command pattern implementation written in Swift 3'

s.homepage = 'https://github.com/intelygenz/Kommander-iOS'
s.homepage = 'https://gitlab.intelygenz.com/ios/kommander'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Alex Rupérez' => '[email protected]', 'Juan Trías' => '[email protected]', 'Roberto Estrada' => '[email protected]' }
s.source = { :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => s.version.to_s }
s.source = { :git => 'https://gitlab.intelygenz.com/ios/kommander.git', :tag => s.version.to_s }

s.ios.deployment_target = '8.0'

Expand Down
8 changes: 4 additions & 4 deletions Kommander.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_COMPATIBILITY_VERSION = 0.2.0;
DYLIB_CURRENT_VERSION = 0.2.1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Kommander/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -369,8 +369,8 @@
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_COMPATIBILITY_VERSION = 0.2.0;
DYLIB_CURRENT_VERSION = 0.2.1;
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/CurrentDispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class CurrentDispatcher: MainDispatcher {
open class CurrentDispatcher: MainDispatcher {

public override init() {
super.init()
Expand Down
14 changes: 7 additions & 7 deletions Kommander/Dispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private enum Priority {
case operation, dispatch
}

public class Dispatcher {
open class Dispatcher {

internal final var operationQueue = OperationQueue()
internal final var dispatchQueue = DispatchQueue(label: UUID().uuidString)
Expand All @@ -33,15 +33,15 @@ public class Dispatcher {
priority = .dispatch
}

public func execute(_ operation: Operation) {
open func execute(_ operation: Operation) {
operationQueue.addOperation(operation)
}

public func execute(_ operations: [Operation], waitUntilFinished: Bool = false) {
open func execute(_ operations: [Operation], waitUntilFinished: Bool = false) {
operationQueue.addOperations(operations, waitUntilFinished: waitUntilFinished)
}

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

public func execute(_ blocks: [() -> Void], concurrent: Bool = true, waitUntilFinished: Bool = false) -> [Any] {
open func execute(_ blocks: [() -> Void], concurrent: Bool = true, waitUntilFinished: Bool = false) -> [Any] {
var actions = [Any]()
if concurrent {
for block in blocks {
Expand All @@ -74,13 +74,13 @@ public class Dispatcher {
return actions
}

public func execute(qos: DispatchQoS?, flags: DispatchWorkItemFlags?, block: @escaping @convention(block) () -> ()) -> DispatchWorkItem {
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
}

public func execute(_ work: DispatchWorkItem) {
open func execute(_ work: DispatchWorkItem) {
dispatchQueue.async(execute: work)
}

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>1.0</string>
<string>0.2.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
12 changes: 6 additions & 6 deletions Kommander/Kommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class Kommand<T> {
open class Kommand<T> {

public typealias ActionBlock = () throws -> T
public typealias SuccessBlock = (_ result: T) -> Void
Expand All @@ -21,23 +21,23 @@ public class Kommand<T> {
private(set) internal final var errorBlock: ErrorBlock?
internal final var action: Any?

internal init(deliverer: Dispatcher, executor: Dispatcher, actionBlock: @escaping ActionBlock) {
public init(deliverer: Dispatcher, executor: Dispatcher, actionBlock: @escaping ActionBlock) {
self.deliverer = deliverer
self.executor = executor
self.actionBlock = actionBlock
}

public func onSuccess(_ onSuccess: @escaping SuccessBlock) -> Self {
open func onSuccess(_ onSuccess: @escaping SuccessBlock) -> Self {
self.successBlock = onSuccess
return self
}

public func onError(_ onError: @escaping ErrorBlock) -> Self {
open func onError(_ onError: @escaping ErrorBlock) -> Self {
self.errorBlock = onError
return self
}

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

public func cancel() {
open func cancel() {
if let operation = action as? Operation, operation.isExecuting {
operation.cancel()
}
Expand Down
10 changes: 5 additions & 5 deletions Kommander/Kommander.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class Kommander {
open class Kommander {

private final let deliverer: Dispatcher
private final let executor: Dispatcher
Expand Down Expand Up @@ -48,19 +48,19 @@ public class Kommander {
executor = Dispatcher(label: name, qos: qos, attributes: attributes, autoreleaseFrequency: autoreleaseFrequency, target: target)
}

public 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)
}

public 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))
}
return kommands
}

func execute<T>(_ kommands: [Kommand<T>], concurrent: Bool = true, waitUntilFinished: Bool = false) {
open func execute<T>(_ kommands: [Kommand<T>], concurrent: Bool = true, waitUntilFinished: Bool = false) {
let blocks = kommands.map { kommand -> () -> Void in
return {
do {
Expand All @@ -81,7 +81,7 @@ public class Kommander {
}
}

func cancel<T>(_ kommands: [Kommand<T>]) {
open func cancel<T>(_ kommands: [Kommand<T>]) {
for kommand in kommands {
kommand.cancel()
}
Expand Down
2 changes: 1 addition & 1 deletion Kommander/MainDispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class MainDispatcher: Dispatcher {
open class MainDispatcher: Dispatcher {

public init() {
super.init(name: nil, qos: nil, maxConcurrentOperationCount: OperationQueue.defaultMaxConcurrentOperationCount)
Expand Down

0 comments on commit 64ec60f

Please sign in to comment.