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.


    Map Click Event Streams to Load Data with Vue.js and RxJS

    John LindquistJohn Lindquist
    5.5.12 - 6.4.0

    This lesson shows how to domStreams with v-stream on a button inside of a Vue.js template, map the click to a data request with RxJS streams, then return that data back into the Vue.js template.



    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




    Instructor: Now, instead of directly loading the person, let's click and then load it. The way that we do that is by, instead of mapping, we do what's called a switch map, and the switch map takes a function and returns an observable. I'm going to return the observable of people.

    Instead of calling this random, let's call it something like Luke, because that's who it's going to load. We'll put in Luke here, and make sure that Luke shows up here. Now, when I click on this button, you'll see that Luke loads in. If I change this to a two, it won't load Luke anymore.

    Instead, when I click, it'll load C-3PO. But we'll go ahead and keep that one for now. I'll click and load in Luke.