Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

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

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Pass Template Data Through domStreams in Vue.js and RxJS

    John LindquistJohn Lindquist

    domStreams enable you to pass additional data along the stream that can be provided by the template (such as data coming from a v-for rendering of an Array). You can then pluck off the data from the stream and use it further down the stream.

    vueVue.js
    ^2.0.0
    rxjsRxJS
    ^5.0.0
    javascriptJavaScript
    Code

    Code

    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
    Transcript

    Transcript

    Instructor: 00:01 Our domstreams also allow us to pass some data along inside of our configured stream here. If we pass an object along instead of just click, I can say that the subject is the click that's created from the domstream, and the data is just going to be the number one, or this is the id for Luke.

    00:20 If I come down here into my click, I can say pluck the data off, and then map that ID to the string of this, using that ID. I'll hit save here and have the exact same result. What this allows me to do is, if I create three buttons where each of these uses different data -- four is Darth Vader and five is Leia -- I'll just save. Then I can click this one to get Luke, this one to get Darth, and this one to get Leia.

    01:00 Each of these passes a data along. The data comes through the click stream here. You can pluck off the data, and then use that data to map whatever data comes through -- I just named it ID -- pass it along, and use it however you need it.

    Discuss

    Discuss