shou2017.com
JP

What is Angular RxJS

Sun Jul 7, 2019
Sat Aug 10, 2024

What is RxJS

RxJS is a JavaScript library for reactive programming. While RxJS is complex, once understood, it allows you to write complicated data processing in a simple way.

Reactive programming is a programming paradigm where related programs react to received data notifications and perform processes. Thanks to reactive programming, we can think about asynchronous processing more intuitively.

Example:

this.A  Perform b, c, d operations sequentially on A
    .b
    .c
    .d

What is Observable

An Observable can be thought of as a river. Users can release things into this river. For example, users can throw garbage into the river, and you can write processes to remove that garbage.

These processes are called Operators. For example, the distinctUntilChanged method only allows the stream to flow when the current value is different from the previous one.

You can also receive items (like garbage in our example) that weren’t caught upstream. This can be done using the Subscribe method or receiving data with then after executing toPromise.

The mechanism for expanding Observable in template form is the async pipe feature. Using the async pipe allows you to use observables without explicitly executing them with the Subscribe method. Using the async pipe reduces the amount of code in components.

What is Subject

A Subject is a class that allows you to flow an Observable (stream/river) at any timing.

Subject inherits from Observable. In Angular, Subject is used more frequently than Observable.

Angularアプリケーションプログラミング

Tags
RxJS
See Also