Before proceeding forward, there should be a crystal clear concept of Reactive programming.
REACTIVE PROGRAMMING is a programming with asynchronous data streams. A data stream is an object that emits multiple data over time depending upon what library and language you’re using. In Dart we called it ‘Streams’, and in Rx libraries we called it ‘Observables’.
WHAT IS DART?
Dart is an open source general purpose programming language for building flutter applications for modern web. Rx library adds additional functionality to Dart streams and stream controller. This is the combination of techniques and ideas from observer, and functional programming.
Stream in other words is a flow of data which is controlled by a Stream controller. What about Sinks? If we’ve an output of a data flow, we also need an input, that’s what Sinks is employed for. There are two kinds of Steam controller. The one we use when just one person can access then it’s called a ‘Single Subscription stream controller’. This is the kind of stream you get when you read a file or receive a web request. but if more than one or large number of people can access it, let’s say YouTube, then that kind of Stream controller is termed as ‘Broadcast’. This kind of stream can be used for mouse events in a browser.
In Rx Dart, We have different notion of subjects. The broadcast is controlled by behavior subject or replay subject or publish subject. These three are extensions of stream controller.
This one is pretty simple. This Subject allows sending data, error and done events to the listener.
It is actually analogous to publish subject because it also allows sending data, error and done events to the listener, but the newest item that has been added to the topic are going to be sent to any new listeners of the topic.
It allows us the same sending data, error and done events to the listener. But a worth mentioning difference is that, as items are added to the topic, the Replay Subject will store them and when the stream is listened to, those recorded items are going to be emitted to the listener.
In Rx Dart, we have observable which is different from streams in some features. The variables and everything remain same in streams and observables.
WHY RXDART IS ESSENTIAL?
* To manage global state in a flutter app and to leverage the special type of streams .
* It transforms a source stream into fresh new streams with different capabilities such as throttling or buffering events.