• This repository has been archived on 29/Oct/2021
  • Stars
    star
    172
  • Rank 221,201 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lightweight, pure-Swift library for manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.

Kommander

Twitter Version License Platform Swift Carthage compatible Swift Package Manager Compatible Build Status Documentation Downloads Help Contribute to Open Source

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
  • Retry kommand or multiple kommands
  • Set kommand success closure
  • Set kommand error closure
  • Set kommand error closure specifying Error type
  • Main thread dispatcher
  • Current thread dispatcher
  • Custom OperationQueue dispatcher
  • Execute single or multiple Operation
  • Execute sequential or concurrent closures
  • Execute DispatchWorkItem
  • Kommand state
  • iOS compatible
  • watchOS compatible
  • tvOS compatible
  • macOS compatible
  • Swift 4 version
  • 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, cancelling and retrying Kommands:

Kommander().make {
    // Your code here
}.execute()
Kommander().make {
    // Your code here
}.execute(after: .seconds(2))
Kommander().make {
    return "Your string"
}.success { yourString in
    print(yourString)
}.execute()
Kommander().make {
    throw CocoaError(.featureUnsupported)
}.error { error in
    print(String(describing: error!))
}.execute()
Specify Error type:
Kommander().make {
    throw MyError.error
}.error(MyError.self) { error in
    // error is MyError type.
}.execute()
Retry after cancellation:
let kommand = Kommander().make { () -> Any? in
    // Your code here
}.success { result in
    // Your success handling here
}.error { error in
    // Your error handling here
}.execute()

kommand.cancel()

kommand.retry()
Retry after failure:
let kommand = Kommander().make { () -> Any? in
    // Your code here
}.error { error in
    // Your error handling here
}.retry { error, executionCount in
    return executionCount < 2
}.execute()

Creating Kommanders:

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

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

Kommander.current

Kommander.default

Kommander.userInteractive

Kommander.userInitiated

Kommander.utility

Kommander.background

Creating Dispatchers:

CurrentDispatcher()

MainDispatcher()

Dispatcher(name: String, qos: QualityOfService = .default, maxConcurrentOperations: Int = .default)
Shortcuts:
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.

More Repositories

1

Archit-iOS

Intelygenz iOS Architecture
Swift
204
star
2

NetClient-iOS

Versatile HTTP Networking in Swift
Swift
122
star
3

the-real-devops-challenge

This challenge was designed to look for your DevOps skills. This repository contains challenges to demostrates your knowledge.
HCL
33
star
4

IGZLocation

CLLocationManager Swift wrapper with multiple closure handlers and delegates allowed, notifications, sequential geofencing, self-authorization and, of course, everything is testable. #InCodeWeTrust
Swift
31
star
5

lab-microk8s-pod-security-policies

This laboratory is developed to have a first contact with the Pod Security Policies locally using microk8s
Shell
16
star
6

App2WebHandoff

Resume in-app web browsing in the default web-browser of the continuing platform adopting handoff.
Swift
12
star
7

serverless

Docker image containing the Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more!
Makefile
7
star
8

intelygenz.github.io

6
star
9

monorepo-tagger-action

Action to manage tag life-cycle in a mono-repo with multiple components
JavaScript
5
star
10

ansible-image

Ansible Docker Image
Makefile
5
star
11

action-product-version-tags

Github action to manage the versioning life cycle of a product in monorepo
JavaScript
5
star
12

the-real-sre-challenge

This challenge was designed to look for your SRE skills.
Python
2
star
13

github-actions-poc

github-actions-poc
TypeScript
1
star
14

swift-style-guide

1
star
15

bci-x

Brain Computer Interface X is a complete tool to perform experiments with EEG compatible with OpenBCI devices. The focus of BCI-X is to capture raw data while labeling it during experiments in order to facilitate the work with Deep Learning.
1
star