4

I am using RxSwift as part of a project that someone else started.

Wanting to understand a bit more on the theory of ReactiveX I bumped into React Native and Rx.Net.

I would like to make sure I understand the following correctly:

  • React Native is a Java Script library that allows developers to build native user interfaces. The library translates Javascript code into native mobile code.
  • RxSwift aims to implement concepts of Rx.Net but is different and not directly linked to React Native. The commonality is that they both implement concepts of Reactive programming hence why the shared use of the word "React" / "Reactive" in their name. That's where the commonalities should end, right?

Conclusions:

  • As both RxSwift and React Native are tightly connected to the user interface implementation it is not possible to use them together. Correct?
mm24
  • 9,280
  • 12
  • 75
  • 170

2 Answers2

2

RxSwift definition:

RxSwift is a library for composing asynchronous and event-based code by using observable sequences and functional style operators, allowing for parameterized execution via schedulers.

So, basically RxSwift allow you to develop asynchronous apps that react to new data by processing it sequentially.

React Native definition:

React Native lets you build mobile apps using only JavaScript. With React Native, you don't build a “mobile web app”, an “HTML5 app”, or a “hybrid app”. You build a real mobile app that's indistinguishable from an app built using Objective-C or Java. React Native uses the same fundamental UI building blocks as regular iOS and Android apps. You just put those building blocks together using JavaScript and React.

React Native allows you to develop native apps by creating a bridge between the code that you write in Javascript and Objective-C (iOS) or Java (Android).

Considering this, it's possible to guess that you would have to create a bridge to embed a native component in React Native and vice versa. In this case, working with both React Native and RxSwift would be almost impossible as you would probably have to create your own "bridge" library.

If you want to use the benefits of FRP (Functional Reactive Programming) with Javascript code, I would recommend you to check out RxJs: https://github.com/Reactive-Extensions/RxJS

Alexandre Lara
  • 2,464
  • 1
  • 28
  • 35
2

RxSwift is an implementation of Reactive Extensions created by Microsoft. A library which basically allows you to use Observables, which are objects that instead of containing a specific value, they contain all the future values of that object. Other objects can then transform and subscribe to those values.

It's very useful for dealing with asyncrhonous programming.

React Native is a framework created by Facebook for building apps for different platforms in Javascript. The great thing about it is that the UI is native for every platform and that the rest of the code can be shared between them.

So, both are two completely different things, but you could kind of use them together, only that React Native being Javascript, you'll have to use RxJS instead.

Here's a list of the different languages Reactive Extensions were ported to: http://reactivex.io

By the way, if what you want is just learning RxSwift, read this book: https://store.raywenderlich.com/products/rxswift

Odrakir
  • 4,254
  • 1
  • 20
  • 52