Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Update RxJS to 5.x

    An overview of RxJS reactive concepts

    André StaltzAndré Staltz
    4 - 5

    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.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    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.

    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.

    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.

    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.

    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.

    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.

    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.

    That's it and I hope you enjoyed learning about reactive programming in JavaScript.