Learn RxJava

About this sentence

Record what you learned to use RxJava as a memorandum. If you have any mistakes, I would appreciate it if you could comment.

reference

I didn't understand reactive programming, so I summarized it. http://system.blog.uuum.jp/entry/%E3%83%AA%E3%82%A2%E3%82%AF%E3%83%86%E3%82%A3%E3%83%96%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E3%81%B8%E3%81%AE%E7%90%86%E8%A7%A3%E3%81%8C%E3%82%A4%E3%83%9E%E3%82%A4%E3%83%81%E3%81%A0%E3%81%A3 It summarizes reactive programming.

"RxJS" Beginners-A library that changes the common sense of asynchronous processing of JavaScript http://liginc.co.jp/web/js/151272 About ReactivX, Observle pattern is summarized. Mainly RxJavaSclipt, but can be used for other purposes.

What is RxJava

A library that makes ReactiveX available in Java, ReactiveX official website: http://reactivex.io/

So you need to learn about ReactiveX first.

Reactive X

Quoted from the official website

ReactiveX is a library for composing asynchronous and event-based programs by using observable sequences.

In other words, it seems that asynchronous processing and event-based processing are realized by the * Obserble pattern *.

So what is the ** Observle sequence **? Talk

If you read further, you will find the following sentences.

It is sometimes called “functional reactive programming” but this is a misnomer. ReactiveX may be functional, and it may be reactive, but “functional reactive programming” is a different animal. 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.

Similar to ** FRP ** (functional reactive programming), but it works for continuous values over time, ReactiveX works for individual values ...?

The question here is what is FRP.

In the first place, this exists to solve what, and I searched for various things about what is good, but it's hard to come up with a pin. But the underlying thing is that ** asynchronous processing ** is more convenient and easier! There seems to be something like that.

What you want to solve: Problems with asynchronous processing

Asynchronous processing is commonplace in recent systems (especially Web applications), and the demand for it is steadily increasing. However, asynchronous has the problem that it becomes difficult to grasp as the system grows, and it becomes difficult to handle errors due to callback hell.

Of course, there are many libraries that can solve the above problems, but one of them is ReactiveX, and it seems that RxJavaSclipt was adopted by Microsoft and made for JavaSclipt.

So how do you solve it, for that you learn backbone knowledge such as Observle sequences

About Obserble sequence

The following site was very easy to understand. http://liginc.co.jp/web/js/151272

Events flow as a series (Stream), which is called an Obserble sequence.

Users who want to receive events register Obserber. Register this Obserber registration by Subscribe as follows.

Obserble.subscribe(new observer(...));

You can take specific action on Obserble before it is notified to Obserber, This is called ** Operation **.

Observable
    .filter() //Operation
    .map(User::getName) //Operatioin

.filter, .map, etc ... These functions that come with Obeserble can be connected like a method chain because they return the processed Obserble as a return value at the same time.

Observer OnNext () representing the next task OnComplete () to indicate the end of work OnError () representing an error There are three methods.

Obserbale calls these three methods along the flow, but this work is done by the emitter.


Working

Recommended Posts

Learn RxJava
Learn Docker roughly