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

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

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 9 months ago

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.

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

[00:26] 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 person.name. Hit Save there, and there's no visual change, it's just updated to use my set of data.

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

[01:19] 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...

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today