Reactive programming for Quantum SDK
It is an asynchronous programming paradigm concerned with data streams and the propagation of change.
In other words, programming that working with asynchronous data streams.
It is a library for composing asynchronous and
event-based programs by using observable sequences.
ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming.
We can assume Observer pattern as a Publish-Subscribe
ReactiveX makes it very easy to do reactive programming because
Manipulate UI events and API responses, on the Web with RxJS, or on mobile with Rx.NET and RxJava
Available for idiomatic Java, Scala, C#, C++, Clojure, JavaScript, Python, Groovy, JRuby, and others
Embrace ReactiveX's asynchronicity, enabling concurrency and implementation independence
ReactiveX is everywhere, and it's meant for everything.
Collection that arrives over time. Can be transformed, combined, and consumed using the operators that ReactiveX provides.
Observable content consumer. Reacts to whatever item or sequence of items the Observable emits. It's a collection of callbacks: success, error, complete
{
next: value => console.log(`Observer got a next value: ${value}`),
error: error => console.error(`Observer got an error: ${error}`),
complete: () => console.log('Observer got a complete notification'),
};
The subscription represents the observable execution. The subscription could be canceled
.subscribe(response => {
...
});
.unsubscribe();
Transform the items emitted by an Observable by applying a function to each item
Apply a function to each item emitted by an Observable, sequentially, and emit each successive value
Register an action to take upon a variety of Observable lifecycle events
filter, delay ,merge, take
...
1. Creating observables for global events
2. Creating observables for entity events
Pros | Cons |
---|---|
Let’s user operate events before events resolution and allows event unsubscription. | Leads to chaining pattern |
Easy integration with entity manager | Code hard to debug and test |