An overview of RxJS reactive concepts

André Staltz
InstructorAndré Staltz
Share this video with your friends

Social Share Links

Send Tweet

This video gives an overview of the concepts of reactive programming we saw during this series, and explains how reactive programming can provide true separation of concerns.

[00:00] Let's zoom out a bit and see what we accomplished. The first thing that you notice from this code, it basically only has var declarations and function definitions. It's a fully declarative code.

[00:13] Apart from, of course, the subscribes here at the bottom. These look somewhat familiar. They are not that much different from document.addEventListener. Giving a custom event such as suggestion one, and a call back. This is pretty much the same idea as this.

[00:36] How did we create our custom events? Well, we did that by applying functions, such as map and merge and flatMap, based on simpler events, such as response, stream, and close, click streams and refresh click streams. That kind of stuff.

[00:55] We learned that everything can be an event stream. We can have an event streams of clicks. We can have event streams for promises, and we can have event streams, also, for data, such as these.

[01:08] Then also look at how we have virtually no control flow keywords here. We don't have ifs, we don't have elses, we don't have for-loops. All of this was created with operators such as map and filter and flatMap. These operators are really important for programming, and they will be your new ifs and for-loops.

[01:34] Finally, let's look how reactive programming brought true separation of concerns to our code. If you want to see how the first user data behaves over time, you only need to look at its declaration.

[01:48] The declaration specifies the complete dynamic behavior over time. There cannot be any other code that will modify the user data. That's a really good guarantee. You can be sure you know, 100 percent, how the user data works just by looking at its definition.

[02:09] That's it and I hope you enjoyed learning about reactive programming in JavaScript.