Skip to content

Kommander is a Swift library to manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.

License

Notifications You must be signed in to change notification settings

juantrias/Kommander-iOS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kommander

Twitter Version License Platform Carthage compatible Swift Package Manager Compatible Build Status Downloads

Kommander is a Swift library to manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.

Inspired on the Java library Kommander from Wokdsem.

Kommander

Features

  • Make kommand or multiple kommands
  • Execute kommand or multiple kommands
  • Cancel kommand or multiple kommands
  • Set kommand success block
  • Set kommand error block
  • Main thread dispatcher
  • Current thread dispatcher
  • Custom OperationQueue dispatcher
  • Execute single or multiple Operation
  • Execute sequential or concurrent blocks
  • Execute DispatchWorkItem
  • Kommand state
  • watchOS compatible
  • tvOS compatible
  • Swift 3 version
  • Swift 2 version
  • Objective-C version

Installation

Kommander is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Kommander'

For Swift 3 compatibility use:

pod 'Kommander', '~> 0.7'

For Swift 2 compatibility use:

pod 'Kommander', :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => '0.3.0-swift2'

For Objective-C compatibility use:

pod 'Kommander', :git => 'https://github.com/intelygenz/Kommander-iOS.git', :tag => '0.2.3-objc'

Or you can install it with Carthage:

github "intelygenz/Kommander-iOS"

Or install it with Swift Package Manager:

dependencies: [
    .Package(url: "https://github.com/intelygenz/Kommander-iOS.git")
]

Usage

Making, executing and cancelling Kommands:

Kommander().makeKommand {
    // Your code here
}.execute()
Kommander().makeKommand {
    // Your code here
}.execute(after: .seconds(2))
Kommander().makeKommand {
    return "Your string"
}.onSuccess { yourString in
    print(yourString)
}.execute()
Kommander().makeKommand {
    throw CocoaError(.featureUnsupported)
}.onError({ error in
    print(String(describing: error!))
}).execute()
let kommand = Kommander().makeKommand { () -> Any? in
    // Your code here
}.onSuccess { result in
    // Your success handling here
}.onError({ error in
    // Your error handling here
}).execute()

kommand.cancel()

Creating Kommanders:

Kommander(deliverer: Dispatcher = .current, executor: Dispatcher = .default)

Kommander(deliverer: Dispatcher = .current, name: String, qos: QualityOfService = .default, maxConcurrentOperationCount: Int = .default)
Kommander.main

Kommander.current

Kommander.default

Kommander.userInteractive

Kommander.userInitiated

Kommander.utility

Kommander.background

Creating Dispatchers:

CurrentDispatcher()

MainDispatcher()

Dispatcher(name: String, qos: QualityOfService = .default, maxConcurrentOperationCount: Int = .default)
Dispatcher.main

Dispatcher.current

Dispatcher.default

Dispatcher.userInteractive

Dispatcher.userInitiated

Dispatcher.utility

Dispatcher.background

Etc.

  • Contributions are very welcome.
  • Attribution is appreciated (let's spread the word!), but not mandatory.

Authors

alexruperez, [email protected]

juantrias, [email protected]

RobertoEstrada, [email protected]

License

Kommander is available under the MIT license. See the LICENSE file for more info.

About

Kommander is a Swift library to manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.2%
  • Shell 2.6%
  • Ruby 2.2%
  • Objective-C 1.0%