You will really appreciate the power of RxJava when you write a thread management program. Now, you must be thinking why RxJava is so popular then? So, RxJava only has some patterns similar to the principles of Functional programming. One main point of difference is that functional reactive programming operates on values that change continuously over time, while ReactiveX operates on discrete values that are emitted over time. ReactiveX may be functional, and it may be reactive, but “functional reactive programming” is a different animal. The doc says: It is sometimes called “ functional reactive programming” but this is a misnomer. Also to make things look more enhanced, Functional is associated with the RxJava. These are just fancy words for a Publisher-Subscriber library. Now you must think, what’s new about it? We have been doing these for decades. Here, observer pattern is the key to understand the architecture, which is a software design pattern, where Subject maintains its Observers and notifies them automatically of any state change, usually by calling one of their methods. The Reactive Extension is further elaborated: It extends the observer pattern to support sequences of data and/or events and adds operators that allow you to compose sequences together declaratively while abstracting away concerns about things like low-level threading, synchronization, thread-safety, concurrent data structures, and non-blocking I/O. We can plug in various transformations that resembles the Functional programming. RxJava free us from the callback hell by providing the composing style of programming.So, we will come back to it later in this article. Observable sequences: It will be better understood by the mechanics of it.For Example, a Button click triggers an event and then the program’s event handler receives this event and does some work. Event-Based: The program executes the codes based on the events generated while the program is running.Asynchronous: It implies that the different parts of a program run simultaneously.The definition presents three different terms: asynchronous, event-based, and observable sequences. The official doc describes Reactive Extension(ReactiveX) as a library for composing asynchronous and event-based programs by using observable sequences. RxJava is a Java VM implementation of Reactive Extensions. Let’s start with the official definition of RxJava from its GitHub repository: Definition: This article is not a guide on how to use RxJava features but a more fundamental exploration, what it is that RxJava is solving in our codebase and how it is doing it? There are a huge number of articles and tutorials written on how to use RxJava, then why I am writing this redundant article? Most of you must have worked with it in some form, either in your own codebase or through other third party libraries, like Retrofit. RxJava has become the single most important skill for Android development.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |