Latest 1.0.0
Homepage https://github.com/laxmorek/RxExternalAccessory
License MIT
Platforms ios 10.0
Dependencies RxSwift
Frameworks ExternalAccessory
Authors

Swift
Version
License
Platform

RxSwift wrapper around ExternalAccessory framework

Instalation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate RxExternalAccessory into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

pod 'RxExternalAccessory'

Then, run the following command:

$ pod install

Usage

Create RxEAAccessoryManager instance:

let rx_manager = RxEAAccessoryManager()

Available actions:

// tries to open session with first match from available accessories for given `supportedProtocols`
rx_manager.tryConnectingAndStartCommunicating(forProtocols: supportedProtocols)

// tries to open session for given `EAAccessory`
rx_manager.tryConnectingAndStartCommunicating(to: accessory, forProtocols: supportedProtocols)

// stops any working sessions
rx_manager.stopCommunicating()

You can observe:

// available accessories - Observable<[EAAccessory]>
rx_manager.connectedAccessories
    .subscribe(onNext: { accessories in
        // DO SOMETHING
    })
    .disposed(by: disposeBag)

// current opened session (nil if any session on) - Observable<EASession?>
rx_manager.session
    .subscribe(onNext: { session in
        // DO SOMETHING
    })
    .disposed(by: disposeBag)

// calls from `StreamDelegate` - Observable<StreamResult> where StreamResult = (aStream: Stream, eventCode: Stream.Event)
rx_manager.streamResult
    .subscribe(onNext: { stream, eventCode in
        switch (stream, eventCode) {
        case (let inputStream as InputStream, .hasBytesAvailable):
            // DO SOMETHING
            break
        default:
            break
        }
    })
    .disposed(by: disposeBag)

Contributing

Bug reports and pull requests are welcome.

License

RxExternalAccessory is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "RxExternalAccessory",
    "version": "1.0.0",
    "summary": "RxSwift wrapper around ExternalAccessory framework",
    "homepage": "https://github.com/laxmorek/RxExternalAccessory",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kamil Harasimowicz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/laxmorek/RxExternalAccessory.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "RxExternalAccessory/Sources/**/*.swift",
    "frameworks": "ExternalAccessory",
    "dependencies": {
        "RxSwift": [
            "~> 4.0"
        ]
    }
}

Pin It on Pinterest

Share This