Swiftpack.co - Package - MoveUpwards/RxSejima

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

MoveUpwards/RxSejima

Add Bind capabilities to Sejima library

Documentation Language: Swift 2, 3 and 4 Platform: iOS 11+ Carthage Compatible CocoaPods Codacy Badge Build Status License: MIT GitHub contributors Donate

RxSejima

Add Bind capabilities to Sejima library

Requirements

  • iOS 9.0+
  • Xcode 9.0+

Installation

use CocoaPods with Podfile

pod 'RxSejima'

open your favorite terminal, go to your project root path:

pod install

use Carthage with Cartfile

github "MoveUpwards/RxSejima"

open your favorite terminal, go to your project root path and run:

carthage update

Usage

Create a basic view controller with a MUButton

import Sejima
import RxSejima

class ViewController: UIViewController {
    @IBOutlet private var button: MUButton!

    private let bag = DisposeBag()
    private let viewModel: ViewControllerViewModel()

    override func viewDidLoad() {
        super.viewDidLoad()

        viewModel.loading.bind(to: button.rx.loading).disposed(by: bag)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        startLoading()
    }
}

Add your view model with the logic.

import RxSwift

class ViewControllerViewModel {
    internal let loading = BehaviorSubject<Bool>(value: false)

    internal func startLoading() {
        loading.onNext(true)
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
            self?.loading.onNext(false)
        }
    }
}

Github

link
Stars: 4
Last commit: 38 weeks ago

Releases

Add bindable properties - 2019-05-31T15:00:13

Add isLoading binding on MUCollectionButton