⚠️ This lesson is retired and might contain outdated information.

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

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet

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.

Instructor: [00:00] 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.

[00:17] 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.

[00:38] 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.