Latest 0.0.4
Homepage https://github.com/SwiftReactive/ReactiveCommander
License MIT
Platforms tvos 9.0, ios 8.0, osx 10.10, watchos 2.1, requires ARC
Authors

image

Carthage compatible
Build Status
[CocoaPods]()
GitHub release

Requirements

Installation

CocoaPods

You can install ReactiveCommander using CocoaPods adding the following lines to your Podfile:

use_frameworks!
pod "RXCommander" // For RxSwift
pod "RACCommander" // For ReactiveCocoa

Wherever you want to use the framework import it with import ReactiveCommander

Carthage

It’s also available to install using Carthage

github "SwiftReactive/ReactiveCommander"

Depending on the framework you want to use ReactiveCocoa or RxSwift you’ll have to add to your project, RACCommander or RXCommander respectively. Then import them with these names.

Minimum Version supported

  • tvOS – 9.0
  • iOS – 8.0
  • OSX – 10.10
  • watchOS – 2.1

Contribute

  • Git clone the repository: git clone https://github.com/swiftreactive/ReactiveCommander
  • Install Carthage: brew install carthage
  • Update Carthage dependencies: carthage update
  • Open the project ReactiveCommander.xcodeproj

Components

ReactiveCommander implements the programming command pattern using NSOperationQueue and a Reactive approach. The idea of that pattern is encapsulating operations in command that are initialized with the required parameters to executed the action. These commands can be scheduled in a queue that will manage the threading, concurrency and execution of these commands.

Command

  • Command: Default generic command where T is the returned type. This command has to be overriden before being used implementing the public func action() throws -> T method.

CommandQueue

  • Commands can be enqueued in the CommandQueue which is a subclass of NSOperationQueue with a new method:

    // ReactiveCocoa
    func addCommand<T, E: ErrorType>(cmd: Command<T, E>) -> SignalProducer<T, E>
    
    // RxSwift
    public func addCommand<T>(cmd: Command<T>) -> Observable<T>

    When the SignalProducer is started or the Observable gets a subscriber, the command is added to the queue in order to be executed.

  • CommandQueue provides a singleton instance that can be accessed with CommandQueue.backgroundQueue. If you want to implement your own queue with your own NSOperationQueue configuration you can just subclass this class.
  • ReactiveCommander provides a custom operator to be used with Command and CommandQueues:
    • let disposable = queue <~ command – Enqueues the command and return the disposable.

Notes

  • Commands actions must be synchronous. The asynchrony is handled by the queue.
  • Commands must represent isolated operations and complex relations between them should be avoided.

License

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

Latest podspec

{
    "name": "ReactiveCommander",
    "version": "0.0.4",
    "summary": "Command Pattern foundation components based on Reactive",
    "description": "Command Pattern foundation components based on Reactive",
    "homepage": "https://github.com/SwiftReactive/ReactiveCommander",
    "license": "MIT",
    "authors": {
        "@pepibumur": "[email protected]"
    },
    "source": {
        "git": "https://github.com/SwiftReactive/ReactiveCommander.git",
        "tag": "0.0.4"
    },
    "default_subspecs": "RX",
    "platforms": {
        "tvos": "9.0",
        "ios": "8.0",
        "osx": "10.10",
        "watchos": "2.1"
    },
    "requires_arc": true,
    "subspecs": [
        {
            "name": "RX",
            "source_files": [
                "ReactiveCommander/Source/RX/**/*.{swift}"
            ],
            "dependencies": {
                "RxSwift": [
                    "~> 2.0.0-beta"
                ],
                "RxCocoa": [
                    "~> 2.0.0-beta"
                ],
                "RxBlocking": [
                    "~> 2.0.0-beta"
                ]
            }
        },
        {
            "name": "RAC",
            "source_files": [
                "ReactiveCommander/Source/RAC/**/*.{swift}"
            ],
            "dependencies": {
                "ReactiveCocoa": [
                    "~> 4.0.0-RC.1"
                ]
            }
        }
    ]
}

Pin It on Pinterest

Share This