Redux & RxJS, any similarities?
Redux is a just a state management library coming with well defined standards for update operations. As far as you stick with the standards you can keep your data flow sane and easy to reason. It also brings the ability to enhance the data flow with middlewares and store enhancers.
RxJS is a toolkit for reactive programming. You can actually think of every thing happening in your app as a stream. RxJS gives a very rich tool set to manage those streams.
Where RxJS and Redux intercepts? In redux you update your state with actions and obviously these actions can be treated as streams. Using a middleware like redux-observable (you don't have to) you can implement your so called "business logic" in a reactive way. Another thing is that you can create an observable from your redux store which sometimes might be easier than using an enhancer.
To put it in short:
Redux: Flux inspired Library used for State Management.
RxJS: It is another Javascript library based on the reactive programming philosophy, used to deal with "Streams" (Observables, etc.) [Read about Reactive Programming to understand the Stream concepts].
They are very different things.
RxJS can be used to do Reactive Programming and is a very thorough library with 250+ operators.
And Redux is as described on the github repo "Redux is a predictable state container for JavaScript apps".
Redux is just a tool to handle state in apps. But in comparison you could build a full app in just RxJS.
Hope this helps :)
In short, they are very different libraries for very different purposes, but yes there are some vague similarities.
Redux is a tool for managing state throughout the application. It is usually used as an architecture for UIs. Think of it as an alternative to (half of) Angular.
RxJS is a reactive programming library. It is usually used as a tool to accomplish asynchronous tasks in JavaScript. Think of it as an alternative to Promises.
Reactive programming is a paradigm (way of working and thinking) where data changes are observed from a distance. Data is not changed from a distance.
Here is an example of changed from a distance:
// In the controller.js file
model.set('name', 'George');
The Model is changed from the Controller.
Here is an example of observed from a distance:
// logger.js
store.subscribe(function (data) {
console.log(data);
});
In the Logger, we observe the data changes that happen in Store (from a distance), and write to the console.
Redux uses the Reactive paradigm just a little bit: the Store is reactive. You do not set its content from a distance. That's why there is no store.set()
in Redux. The Store observes actions from a distance, and changes itself. And the Store allows others to observe its data from a distance.
RxJS also uses the Reactive paradigm, but instead of being an architecture, it gives you basic building blocks, Observables, to accomplish this "observing from a distance" pattern.
To conclude, very different things for different purposes, but share some ideas.