Skip to content
RxResponderChain
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Resources
RxResponderChain.xcodeproj
Sources
Tests
.gitignore
.swift-version
.swiftlint.yml
Cartfile
Cartfile.private
Cartfile.resolved
LICENSE
Package.swift
README.md
RxResponderChain.podspec

README.md

RxResponderChain

RxResponderChain is an extension of RxSwift, RxCocoa. It provides the way to notify Rx events via responder chain.

Usage

First, you have to create struct / class / enum represents event you want to notify using ResponderChainEvent protocol.

import RxResponder

struct LikeTweetEvent: ResponderChainEvent {
    let tweetID: Int64
}

Generate event object and pass it to bindTo (or, on, onNext … ).

final class TweetCell: UITableViewCell {
    ...

    override func awakeFromNib() {
        super.awakeFromNib()

        likeButton.rx.tap
            .map { _ in LikeTweetEvent(tweetID: self.tweet.id) }
            .bind(to: self.rx.responderChain)
            .disposed(by: disposeBag)
    }
}

Then you can receive events in classes that are on responder chain of the class sends events. For example, if you send event in UITableViewCell then you can receive them in tableView, viewController.view, viewController, viewController.navigationController, and so on.

final class TweetListViewController: UIViewController {
    ...

    override func viewDidLoad() {
        super.viewDidLoad()

        self.rx.responderChain.event(LikeTweetEvent.self)
            .flatMapFirst { e in twitterService.like(tweetID: e.tweetID) }
            .subscribe()
            .disposed(by:disposeBag)
    }
}

Requirements

RxResponderChain requires / supports the following environments:

  • Swift 4.1 / Xcode 9.3
  • iOS 9.0 or later
  • RxSwift / RxCocoa ~> 4.1

Installation

Carthage

github "ukitaka/RxResponderChain" ~> 2.0

CocoaPods

use_frameworks!
pod "RxResponderChain", "~> 2.0"
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.