All Projects β†’ CombineCommunity β†’ Rxcombine

CombineCommunity / Rxcombine

Licence: mit
Bi-directional type bridging between RxSwift and Apple's Combine framework

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Rxcombine

Awesome Reactive Programming
A repository for sharing all the resources available on Reactive Programming and Reactive Systems
Stars: ✭ 163 (-78%)
Mutual labels:  reactive, reactive-programming, reactive-streams
Rx.Http
A reactive way to make HTTP Request in .NET Core πŸš€
Stars: ✭ 62 (-91.63%)
Mutual labels:  reactive, reactive-streams, reactive-programming
netifi-quickstart-java
Project to assist you in getting started using Netifi.
Stars: ✭ 23 (-96.9%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Rxswift To Combine Cheatsheet
RxSwift to Apple’s Combine Cheat Sheet
Stars: ✭ 1,040 (+40.35%)
Mutual labels:  reactive, reactive-programming, rxswift
reacted
Actor based reactive java framework for microservices in local and distributed environment
Stars: ✭ 17 (-97.71%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Rsocket Rpc Java
Standard RSocket RPC Java Implementation
Stars: ✭ 126 (-83%)
Mutual labels:  reactive, reactive-programming, reactive-streams
KotlinReactiveMS
An educational project to learn reactive programming with Spring 5 and Kotlin
Stars: ✭ 33 (-95.55%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Rerxswift
ReRxSwift: RxSwift bindings for ReSwift
Stars: ✭ 97 (-86.91%)
Mutual labels:  reactive-programming, rxswift, frp
purescript-pop
πŸ˜ƒ A functional reactive programming (FRP) demo created with PureScript events and behaviors.
Stars: ✭ 33 (-95.55%)
Mutual labels:  reactive, reactive-programming, frp
SwiftObserver
Elegant Reactive Primitives for Clean Swift Architecture #NoRx
Stars: ✭ 14 (-98.11%)
Mutual labels:  reactive, rxswift, reactive-programming
Rxjava2 Jdbc
RxJava2 integration with JDBC including Non-blocking Connection Pools
Stars: ✭ 360 (-51.42%)
Mutual labels:  reactive, reactive-programming, reactive-streams
Swiftrex
Swift + Redux + (Combine|RxSwift|ReactiveSwift) -> SwiftRex
Stars: ✭ 267 (-63.97%)
Mutual labels:  reactive-programming, rxswift, frp
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (-94.6%)
Mutual labels:  reactive, reactive-programming, reactive-streams
Reactive Ms Example
An educational project to learn reactive programming with Spring 5
Stars: ✭ 157 (-78.81%)
Mutual labels:  reactive, reactive-programming, reactive-streams
Combinerxswiftperformance
A test suite comparing the performance of Combine and RxSwift
Stars: ✭ 154 (-79.22%)
Mutual labels:  reactive-programming, rxswift, frp
springboot-rsocketjwt-example
Example of using JWT with RSocket and Spring Boot
Stars: ✭ 26 (-96.49%)
Mutual labels:  reactive, reactive-streams, reactive-programming
assembler
Functional, type-safe, stateless reactive Java API for efficient implementation of the API Composition Pattern for querying/merging data from multiple datasources/services, with a specific focus on solving the N + 1 query problem
Stars: ✭ 102 (-86.23%)
Mutual labels:  reactive, reactive-streams, reactive-programming
Mp3ID3Tagger
🎢🎡A macOS application to edit the ID3 tag of your mp3 files. Developed with RxSwift and RxCocoa. 🎸🎼
Stars: ✭ 17 (-97.71%)
Mutual labels:  reactive, rxswift, reactive-programming
Entwine
Testing tools and utilities for Apple's Combine framework.
Stars: ✭ 306 (-58.7%)
Mutual labels:  reactive, reactive-programming, reactive-streams
Reactor Core
Non-Blocking Reactive Foundation for the JVM
Stars: ✭ 3,891 (+425.1%)
Mutual labels:  reactive, reactive-streams

subject# RxCombine



Build Status Code Coverage for RxCombine on codecov
RxCombine supports CocoaPods RxCombine supports Swift Package Manager (SPM) RxCombine supports Carthage

RxCombine provides bi-directional type bridging between RxSwift and Apple's Combine framework.

Note: This is highly experimental, and basically just a quickly-put-together PoC. I gladly accept PRs, ideas, opinions, or improvements. Thank you ! :)

Basic Examples

Check out the Example App in the ExampleApp folder. Run pod install before opening the project.

Installation

CocoaPods

Add the following line to your Podfile:

pod 'RxCombine'

Swift Package Manager

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/CombineCommunity/RxCombine.git", from: "1.6.0")

Carthage

Carthage support is offered as a prebuilt binary.

Add the following to your Cartfile:

github "CombineCommunity/RxCombine"

I want to ...

Use RxSwift in my Combine code

RxCombine provides several helpers and conversions to help you bridge your existing RxSwift types to Combine.

Note: If you want to learn more about the parallel operators in Combine from RxSwift, check out my RxSwift to Combine Cheat Sheet (or on GitHub).

  • Observable (and other ObservableConvertibleTypes) have a publisher property which returns a AnyPublisher<Element, Swift.Error> mirroring the underlying Observable.
let observable = Observable.just("Hello, Combine!")

observable
    .publisher // AnyPublisher<String, Swift.Error>
    .sink(receiveValue: { value in ... })
  • Relays and Subjects can be converted to their Combine-counterparts using the toCombine() method, so you can use them as if they are regular Combine Subjects, and have them connected to your existing subjects.
let relay = BehaviorRelay<Int>(value: 0)

// Use `sink` on RxSwift relay
let combineSubject = relay.toCombine()

combineSubject.sink(receiveValue: { value in ... })

// Use `send(value:)` on RxSwift relay
combineSubject.send(1)
combineSubject.send(2)
combineSubject.send(3)

Use Combine in my RxSwift code

RxCombine provides several helpers and conversions to help you bridge Combine code and types into your existing RxSwift codebase.

  • Publishers have a asObservable() method, providing an Observable<Output> mirroring the underlying Publisher.
// A publisher publishing numbers from 0 to 100.
let publisher = AnyPublisher<Int, Swift.Error> { subscriber in
    (0...100).forEach { _ = subscriber.receive($0) }
    subscriber.receive(completion: .finished)
}

publisher
    .asObservable() // Observable<Int>
    .subscribe(onNext: { num in ... })
  • PassthroughSubject and CurrentValueSubject both have a asAnyObserver() method which returns a AnyObserver<Output>. Binding to it from your RxSwift code pushes the events to the underlying Combine Subject.
// Combine Subject
let subject = PassthroughSubject<Int, Swift.Error>()

// A publisher publishing numbers from 0 to 100.
let publisher = AnyPublisher<Int, Swift.Error> { subscriber in
    (0...100).forEach { _ = subscriber.receive($0) }
    subscriber.receive(completion: .finished)
}

// Convert a Publisher to an Observable and bind it
// back to a Combine Subject 🀯🀯🀯
publisher.asObservable()
         .bind(to: subject)

Observable.of(10, 5, 7, 4, 1,  6)
          .subscribe(subject.asAnyObserver())

Future ideas

  • Add CI / Tests
  • Carthage Support
  • Bridge SwiftUI with RxCocoa/RxSwift
  • Partial Backpressure support, perhaps?
  • ... your ideas? :)

License

MIT, of course ;-) See the LICENSE file.

The Apple logo and the Combine framework are property of Apple Inc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].