Skip to content
Add Bind capabilities to Sejima library
Branch: master
Clone or download
damien-nd Merge pull request #3 from MoveUpwards/feature/mu-circular-progress
Add title and detail bindable properties
Latest commit 0dd7218 May 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
RxSejima.xcodeproj
RxSejima.xcworkspace init project Mar 1, 2019
RxSejima Add title and detail bindable properties May 24, 2019
RxSejimaTests init project Mar 1, 2019
docs Set theme jekyll-theme-minimal Mar 4, 2019
.gitignore
Cartfile Add carthage support Mar 1, 2019
LICENSE Initial commit Feb 27, 2019
Podfile Migrate RxSwift to swift 5.0 May 13, 2019
Podfile.lock Migrate RxSwift to swift 5.0 May 13, 2019
README.md Swift 5 May 13, 2019
RxSejima.podspec Update cocoapod spec May 13, 2019

README.md

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)
        }
    }
}
You can’t perform that action at this time.