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.


    Sync Vue.js Components with Streaming Content using $watchAsObservable and RxJS

    5.5.12 - 6.4.0

    Syncing UI and Content is a common scenario. This lesson show how clicking on a tab can load data into a container and keep the selected tab and the data inside the container in sync.



    Become a Member to view code

    You must be a Pro 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
    orLog In




    Instructor: I'm going to refactor out these buttons and move that behavior into these tabs. Something I'll need to do for that is to create an array of people. That's just objects of names, so Luke, an ID of 1, then Darth and Leia. Darth as an ID of 4, and Leia has an ID of 5.

    Now I can pass these people into my tabs. I'll get rid of these. I can v4 on these tab items. I'll say person of people. I can key that against the person.ID, and the label will now be bound to Hit Save there, and there's no visual change, it's just updated to use my set of data.

    In fact, let's throw in Yoda for good measure just to show him. 20 and Yoda. Now we have a Yoda tab. To make sure we load the right person, I'll have to map the active tab IDs to the IDs in our people. That'll look something like removing this .click and saying active tab map. This is the tab ID.

    We want to select this .people tab ID.ID. This ID will find the person and .ID will find this ID. Now with that simple refactor, I hit Save and everything updated perfectly. Hit Darth, click Leia, click Yoda, and everything's working because I simply swapped that click stream for an active tab stream...