Latest / CyberSecurity Summary / Learning Vue: Core Concepts and Practical Patterns for Reusable, Composable, and Scalable User Interfaces
Transcript
- 0:00Speaker 1: Welcome to the deep dive. Today, we're tackling modern web
- 0:03Speaker 1: development by zeroing in on Maya Chavin's Learning View.
- 0:08Speaker 2: Right. It's a great resource.
- 0:09Speaker 1: We've sifted through a lot here preface chapters one, three, thirteen,
- 0:13Speaker 1: basically the whole thing pretty much, and our goal is
- 0:16Speaker 1: to pull out the essential insights, help you grasp why
- 0:19Speaker 1: VJs is, you know, such a major player.
- 0:22Speaker 2: Today, Yeah, and get a solid handle on its core
- 0:24Speaker 2: principles exactly.
- 0:26Speaker 1: So, if you're looking to quickly understand a leading front
- 0:29Speaker 1: end framework, especially View, well, this is your shortcut.
- 0:32Speaker 2: Think of it as a focused tour through the heart
- 0:36Speaker 2: of VIEWJS, using Shavin's book as our guide.
- 0:38Speaker 1: We'll cover everything from setting things up.
- 0:40Speaker 2: To advanced rendering, testing, the whole life cycle.
- 0:43Speaker 1: Really, it's about understanding the well, the elegance and power
- 0:48Speaker 1: view brings precisely. Okay, let's unpack this. Then Shavin kicks
- 0:52Speaker 1: things off by highlighting why learning a framework like view
- 0:54Speaker 1: is just so vital.
- 0:55Speaker 2: Now.
- 0:56Speaker 1: It's not just hype, No, it directly impacts you know,
- 0:59Speaker 1: product quality, development, cost, coding standards.
- 1:02Speaker 2: Even just making development easier, right.
- 1:04Speaker 1: Totally for anyone in web deev front end full stack
- 1:07Speaker 1: knowing a framework like View it's becoming kind of crucial.
- 1:12Speaker 2: That's a really key point. And views rapid growth, especially
- 1:15Speaker 2: back around what twenty eighteen, that really shows its strengths.
- 1:19Speaker 1: It's known for being approachable but also adaptable.
- 1:22Speaker 2: Exactly, it's a user friendly, but you can build serious
- 1:25Speaker 2: stuff with it. We're talking scalable, interactive web apps that
- 1:28Speaker 2: actually perform well.
- 1:30Speaker 1: And Chavin mentions the documentation Apparently it's exceptionally good.
- 1:33Speaker 2: Oh yeah, that's a huge plus. Well written, easy to follow,
- 1:38Speaker 2: makes a big difference when you're.
- 1:39Speaker 1: Learning what's the ecosystem. Tools like view router for navigation,
- 1:43Speaker 1: Pazina for state management, they help streamline setup.
- 1:47Speaker 2: Definitely, having those solid official tools ready to go simplifies
- 1:51Speaker 2: things a lot.
- 1:52Speaker 1: Okay, now this is interesting, Chavine says, if you've used
- 1:54Speaker 1: older tech like Angular JS or like even jQuery, use
- 2:00Speaker 1: API's might feel kind of familiar.
- 2:02Speaker 2: That makes sense. There's a lineage there in some way.
- 2:04Speaker 1: And the template syntax is designed to be easier for
- 2:06Speaker 1: handling data and dom events.
- 2:10Speaker 2: Yeah, lowers that barrier to entry. View manages to blend
- 2:13Speaker 2: that ease of getting started with some really robust capabilities underneath.
- 2:17Speaker 1: So clear epis straightforward. Templates get you going quickly.
- 2:20Speaker 2: But the underlying design lets you build complex things, and
- 2:23Speaker 2: that strong ecosystem, like we said, makes a huge difference.
- 2:26Speaker 1: Okay, so you're sold on View, Where do you actually start?
- 2:29Speaker 1: Let's talk setup. Shavin says, NOJS first, right.
- 2:32Speaker 2: Got to have NOE installing It gives you the node
- 2:34Speaker 2: command itself and also.
- 2:36Speaker 1: MPM, NPM the node package manager. You can check your
- 2:39Speaker 1: version node V.
- 2:41Speaker 2: In the terminal node V easy check.
- 2:43Speaker 1: And NPM is how you grab packages like View itself exactly.
- 2:47Speaker 2: It manages all those external libraries your project depends on.
- 2:50Speaker 2: You check its version with NPMV.
- 2:52Speaker 1: And keep it updated with NPM. Install NPM at latest G.
- 2:56Speaker 2: That mash G is for global right mm hmm makes
- 2:58Speaker 2: it available everywhere on your system. Think of NPM like, well,
- 3:02Speaker 2: it stops you having to manually find and download every
- 3:04Speaker 2: single piece of code you need. It handles the dependencies.
- 3:08Speaker 1: Avoids dependency hell as they say.
- 3:10Speaker 2: Pretty much, Yeah, keeps things organized.
- 3:12Speaker 1: Chavin also mentions yarn though another package manager.
- 3:15Speaker 2: Yeah, it's an alternative to NPM. The book uses yarn
- 3:18Speaker 2: for examples, actually.
- 3:20Speaker 1: So you'd check with yarns get a packages with yarn
- 3:22Speaker 1: ad and install everything for a project with just yarn.
- 3:25Speaker 2: Right, it shows the flexibility you know mpm's default yarn
- 3:28Speaker 2: is Another popular choice point is you need a package manager?
- 3:32Speaker 1: Gotcha? Okay? Note installed package manager ready? What about actually
- 3:37Speaker 1: like building the view project?
- 3:39Speaker 2: So the community is largely shifted now away from the
- 3:43Speaker 2: old view CLI which used Webpack, towards Vite exactly. Vite
- 3:47Speaker 2: is the default now it's fast.
- 3:49Speaker 1: And how do you start a new project with it?
- 3:51Speaker 2: Super simple? Command NPM and itview at latest.
- 3:54Speaker 1: NPM in it view at latest.
- 3:56Speaker 2: Okah, that runs create view, which is the official tool.
- 3:58Speaker 2: It asks you a few questions, sets up the basic
- 4:01Speaker 2: project structure for you.
- 4:02Speaker 1: Why the shift to vite. What makes it faster?
- 4:04Speaker 2: Well? It leverages native es modules in the browser during development,
- 4:08Speaker 2: so instead of budling everything.
- 4:09Speaker 1: Up front like webpac often does.
- 4:11Speaker 2: Right, vites are of code pieces as the browser requests them.
- 4:14Speaker 2: Much faster startup, much quicker updates when you change code.
- 4:18Speaker 2: Big win for developers.
- 4:19Speaker 1: Makes sense. Okay, project set up done? Now? Performance? You
- 4:23Speaker 1: mentioned view as performance Chavine talks about the virtual dom.
- 4:26Speaker 2: Ah, yes, the virtual dom. This is key.
- 4:29Speaker 1: So the browser makes this thing called the dom from
- 4:32Speaker 1: HTML right a tree structure.
- 4:34Speaker 2: Yep, and changing that real dom directly, especially often to
- 4:37Speaker 2: slow It forces the browser to.
- 4:40Speaker 1: Repaint, which is expensive computationally.
- 4:42Speaker 2: Speaking, exactly, especially on complex pages with lots of updates.
- 4:46Speaker 2: Older frameworks sometimes struggled there.
- 4:48Speaker 1: So View's solution is this virtual dom, which is what
- 4:52Speaker 1: exactly a JavaScript object basically.
- 4:55Speaker 2: Yes, it's a lightweight JavaScript representation like a blueprint of
- 4:58Speaker 2: the actual dom v nodes virtual nodes.
- 5:01Speaker 1: Okay, So when data changes in your view app, View.
- 5:04Speaker 2: Updates this virtual dom first, which is super fast, just
- 5:08Speaker 2: changing JavaScript objects in memory.
- 5:10Speaker 1: And then it figures out the best way to update.
- 5:11Speaker 2: The real dom precisely. It calculates the minimum necessary changes
- 5:15Speaker 2: and applies them in batches, like editing a draft before
- 5:19Speaker 2: finalizing the master copy.
- 5:20Speaker 1: So it does a bit more work upfront in JavaScript.
- 5:23Speaker 2: To avoid the much costly er direct dom manipulation.
- 5:27Speaker 1: That's the trade off, and that's why view feel smooth,
- 5:30Speaker 1: especially with frequent updates.
- 5:32Speaker 2: That's a huge part of it. Fewer expensive repaints mean
- 5:34Speaker 2: a more responseive UI.
- 5:36Speaker 1: Okay, cool, So how does a U app actually start?
- 5:39Speaker 1: Chavin mentions a root instance.
- 5:41Speaker 2: Yeah, every view app has a root component instance it's
- 5:44Speaker 2: the foundation.
- 5:45Speaker 1: And other components are nested inside it.
- 5:47Speaker 2: And the whole app gets mounted attached to a specific
- 5:50Speaker 2: HTML element, often a div with eight app you use
- 5:54Speaker 2: app do mount hashtag app.
- 5:55Speaker 1: And configuring these components. The main way is the options API.
- 6:00Speaker 2: That's one of the core ways. Yes, it's basically a
- 6:02Speaker 2: JavaScript object with different properties or options that define the
- 6:06Speaker 2: component's behavior.
- 6:07Speaker 1: Let's break down some key options.
- 6:08Speaker 2: First, data right, Data is a function. Importantly, it returns
- 6:13Speaker 2: an object.
- 6:13Speaker 1: And that object holds the components reactive data exactly.
- 6:17Speaker 2: Reactive means when these properties change, View knows and it
- 6:20Speaker 2: automatically updates the parts of the UI.
- 6:22Speaker 1: That use them, and you use them in the template
- 6:24Speaker 1: with double curly braces.
- 6:25Speaker 2: Yep, property name. That's one way data binding data flows
- 6:29Speaker 2: from the component to the template.
- 6:31Speaker 1: Shaven recommends the viewdev Tools extension here.
- 6:34Speaker 2: Oh absolutely essential. Lets you inspect even edit that reactive
- 6:37Speaker 2: data live in your browser. Great for debugging and understanding
- 6:41Speaker 2: what's happening.
- 6:42Speaker 1: Okay. Then there's v model that's for two way binding.
- 6:44Speaker 2: Correct. It creates a direct link between say, an input
- 6:47Speaker 2: field and a data property.
- 6:48Speaker 1: So user types in the input data updates you change
- 6:51Speaker 1: the data incode input updates.
- 6:53Speaker 2: Exactly, super common for forms, and it has modifiers like
- 6:57Speaker 2: dot trim to remove white.
- 6:58Speaker 1: Space, lazy to update on on blur not every keystroke.
- 7:02Speaker 2: And dot number to try and cast the input to
- 7:04Speaker 2: a number. Handy shortcuts.
- 7:05Speaker 1: What about just binding data to HTML attributes.
- 7:09Speaker 2: One way that's v bind or the shorthand just to colon.
- 7:12Speaker 1: So like ming dot src imager.
- 7:14Speaker 2: Decisely binds the image of data property to the src attribute.
- 7:19Speaker 2: You can bind almost any attribute.
- 7:20Speaker 1: And Shavin says you can bind a whole object.
- 7:23Speaker 2: Yeah, like die dot index, dot index, dot index. If
- 7:27Speaker 2: the object keys match attribute names, view applies them neat and.
- 7:31Speaker 1: You can use the colon for dot class in dot
- 7:34Speaker 1: style too. For dynamic styling.
- 7:36Speaker 2: Definitely, you can bind dot class to an object where
- 7:38Speaker 2: keys are class names and values are booleans, or to
- 7:42Speaker 2: an array of class names. Same idea for dot style
- 7:44Speaker 2: binding to an object of CSS properties. Very flexible.
- 7:48Speaker 1: Okay, what about lists rendering rays of things.
- 7:51Speaker 2: That's the V for directive. You put it on the
- 7:52Speaker 2: element you want to.
- 7:53Speaker 1: Repeat like leaf V for iteman items exactly.
- 7:57Speaker 2: It loops over the items array or object properties and
- 8:00Speaker 2: live for each one and.
- 8:01Speaker 1: The crucial thing here is the dot key attribute.
- 8:04Speaker 2: Absolutely trucal live for item and items key item, dot ID,
- 8:08Speaker 2: you need to give each item a unique key.
- 8:10Speaker 1: Why is that so important?
- 8:11Speaker 2: It helps view track each element efficiently. When the list
- 8:14Speaker 2: changes items added, removed, reordered, View uses the key to
- 8:18Speaker 2: figure out the minimal updates needed. Without keys, it might
- 8:21Speaker 2: have to rerender much more, which hurts performance.
- 8:23Speaker 1: Gotcha keys are essential for list performance now handling user
- 8:28Speaker 1: actions like clicks.
- 8:30Speaker 2: That's v on or the shorthand at say so, at click,
- 8:34Speaker 2: do something.
- 8:35Speaker 1: Attaches an event. Listener calls a method in your component
- 8:37Speaker 1: do something in this case yep.
- 8:39Speaker 2: Or you can put simple inline JavaScript expressions right there
- 8:42Speaker 2: like at click count plus plus meg. But for anything,
- 8:45Speaker 2: complex methods are.
- 8:46Speaker 1: Better, and ven O's modifiers too, like stop and dot prevent.
- 8:49Speaker 2: Right at click. Dot stop prevents the event bubbling up
- 8:52Speaker 2: the dom. At click, dot prevent stops the browser's default action,
- 8:56Speaker 2: like preventing form submission.
- 8:57Speaker 1: There are others too, self not wants.
- 9:00Speaker 2: Dot capture Yeah, dot self means the event must originate
- 9:03Speaker 2: on this specific element, not bubble up from a child.
- 9:06Speaker 2: Johns makes the listener fire only one time. Dot capture
- 9:10Speaker 2: uses the capture phase of event handling, which is less
- 9:14Speaker 2: common but sometimes.
- 9:14Speaker 1: Useful, and specific key modifiers like at keydown dot enter
- 9:18Speaker 1: super handy.
- 9:18Speaker 2: Instead of checking event dot key coode, you just use
- 9:21Speaker 2: a key doown dot enter or at keyp dot shift.
- 9:23Speaker 2: Much cleaner.
- 9:24Speaker 1: You can chain them like at keydown dot ctrl dot enter.
- 9:27Speaker 2: You can, though shaven notes using key coodes like part
- 9:31Speaker 2: one three for enter might be more reliable for complex
- 9:34Speaker 2: chaining than keynames sometimes, and there's dot exact for requiring
- 9:39Speaker 2: only the specified modifiers. Okay.
- 9:41Speaker 1: Last directive in this group conditional rendering showing hiding elements right.
- 9:45Speaker 2: V IF, VLSIF and VLS e if takes an expression.
- 9:49Speaker 1: If it's truth y, the element is rendered exactly.
- 9:52Speaker 2: If it's false, the element isn't just hidden, it's completely
- 9:55Speaker 2: removed from the dom.
- 9:56Speaker 1: And VLS must follow via.
- 9:58Speaker 2: Or vlsif it renders if the preceding VF or vlsf
- 10:02Speaker 2: was false allows you to change conditions.
- 10:04Speaker 1: So VF actually at removes elements, unlike just using CSS
- 10:09Speaker 1: display right.
- 10:10Speaker 2: None correct, it's true conditional rendering, not just toggling visibility. Right.
- 10:15Speaker 1: Okay, Moving on, let's talk component life cycle. Components have stages.
- 10:18Speaker 2: Right, They do from creation to destruction and view gives
- 10:21Speaker 2: you hooks functions you can define to run code at
- 10:24Speaker 2: specific points in that.
- 10:25Speaker 1: Cycle, like what what are some key hooks?
- 10:27Speaker 2: Well, early on you have before creating, created, then before
- 10:30Speaker 2: mountain mounted, just before and after it's added.
- 10:32Speaker 1: To the down mounted sounds useful, like for fetching data.
- 10:36Speaker 2: Exactly common use case. Then when data changes and the
- 10:40Speaker 2: component updates, you get before.
- 10:42Speaker 1: Update and updated, and when it's removed.
- 10:44Speaker 2: For unmounted unmounted Yeah, good for cleanup, like clearing timers
- 10:48Speaker 2: or removing manual event listeners you might have added.
- 10:50Speaker 1: You mentioned the composition API earlier, Shavin talks about a
- 10:53Speaker 1: setup hook related to that.
- 10:55Speaker 2: Yes, setup is the entry point for the composition API.
- 10:59Speaker 2: It actually runs before four before create and create it.
- 11:02Speaker 1: And the script setup syntax kind of hides that complexity, right.
- 11:05Speaker 2: Script setup handles the setup part implicitly, making it more concise.
- 11:09Speaker 2: The setup function gets props and a contact object. What's
- 11:12Speaker 2: in the context useful stuff access to attributes passed to
- 11:16Speaker 2: the component slots which let you pass markup into the component,
- 11:20Speaker 2: and the emit function for sending events up to the parent.
- 11:22Speaker 1: And you can use set up with render functions too.
- 11:24Speaker 1: For really low level control you can.
- 11:26Speaker 2: Yeah, if you need very dynamic rendering logic where templates
- 11:30Speaker 2: get awkward, setup can return render function using the h
- 11:33Speaker 2: function to create v nodes programmatically.
- 11:35Speaker 1: Okay, now, derived data. What if one piece of data
- 11:40Speaker 1: depends on another.
- 11:41Speaker 2: That's what computed properties are for. You use the computed
- 11:43Speaker 2: option and these are cased. Yes, that's the key benefit.
- 11:47Speaker 2: A computed property only recalculates its value if one of
- 11:51Speaker 2: the reactive properties depends on changes. Otherwise, it just returns
- 11:56Speaker 2: the cached value. Very efficient for complex calculations.
- 12:00Speaker 1: But what if you need to do something else when
- 12:02Speaker 1: data changes, like not just calculative value, but run some code,
- 12:06Speaker 1: an API call.
- 12:07Speaker 2: That's where watchers come in the watch.
- 12:09Speaker 1: Option, so you watch a specific data property and.
- 12:12Speaker 2: Provide a callback function that runs whenever that property changes.
- 12:15Speaker 1: It's for side effects, and you have options like deep
- 12:18Speaker 1: for watching inside objects yep, deep.
- 12:20Speaker 2: True watches nested properties, and immediate true makes the watcher
- 12:23Speaker 2: run once right away when the component is created, not
- 12:26Speaker 2: just unchanges makes sense.
- 12:27Speaker 1: Okay. Communication between components. How does a parent talk to a.
- 12:31Speaker 2: Child primarily through props? Props are like custom attributes.
- 12:34Speaker 1: You passed down using v bind or the cull in
- 12:36Speaker 1: shorthand like child component message parent.
- 12:39Speaker 2: Data exactly, and the child component has to declare the
- 12:41Speaker 2: props it expects using the props option.
- 12:44Speaker 1: Or define crops in script setup.
- 12:47Speaker 2: Right, you can specify types for props, make them required,
- 12:50Speaker 2: give them default values. It's a clear contract.
- 12:52Speaker 1: How does the child talk back to the parent.
- 12:54Speaker 2: By emitting custom events? The child calls this emit event
- 12:59Speaker 2: name optional pay load in the options API.
- 13:02Speaker 1: Or uses the emit function from setup or define up
- 13:05Speaker 1: in script setup, and.
- 13:06Speaker 2: The parent listens for that event using v on or
- 13:09Speaker 2: at on the child component tag like child component at
- 13:12Speaker 2: event name, handle event.
- 13:14Speaker 1: Okay, props down events up. What if components are nested
- 13:17Speaker 1: really deep? Passing drops through many levels sounds tedious?
- 13:21Speaker 2: It can be. That's where provide an inject come in
- 13:23Speaker 2: a great inject Yeah, a parent or ancestor component can
- 13:26Speaker 2: provide some data or functionality.
- 13:28Speaker 1: And any descendant component, no matter how deep, can inject.
- 13:31Speaker 2: It exactly bypasses all the intermediate components. Great for global
- 13:34Speaker 2: things like user authentication, status or theme settings.
- 13:37Speaker 1: Cool. And one more thing here, teleport what's that?
- 13:40Speaker 2: Telecord is neat It lets you render a part of
- 13:42Speaker 2: your component's template somewhere else of the dom entirely.
- 13:45Speaker 1: Like outside the component's normal place.
- 13:48Speaker 2: Right. Think modals or pop up notifications. You might want
- 13:51Speaker 2: them rendered directly under the body tag to avoid CSSZ
- 13:54Speaker 2: index issues or clipping from parent elements.
- 13:57Speaker 1: So you use teleport to hashtag modal, target or something.
- 14:00Speaker 2: Actly. You specify the target selector using the two problems.
- 14:03Speaker 1: All right, let's circle back to the composition API. Chavin
- 14:06Speaker 1: covers it extensively. It's an alternative way to organize component logic.
- 14:10Speaker 2: Yes using functions. The core ideas are ref and reactive.
- 14:15Speaker 1: For a primitive values like strings or numbers.
- 14:18Speaker 2: Generally yes, or when you need to potentially reassign the
- 14:21Speaker 2: whole thing. It wraps the value in an object and
- 14:24Speaker 2: you access it using dot value, So my.
- 14:26Speaker 1: Ref dot value to get or set the value.
- 14:29Speaker 2: Correct and reactive is for objects or rays. It makes
- 14:32Speaker 2: the object itself reactive.
- 14:34Speaker 1: So you just modify properties directly on the reactive object.
- 14:36Speaker 2: Yep, my reactive object dot property, new value, view tracks.
- 14:40Speaker 1: It and computed properties and watchers exist in the composition
- 14:44Speaker 1: API two.
- 14:45Speaker 2: They do you import and use computed and watch or
- 14:48Speaker 2: watch effect functions.
- 14:49Speaker 1: The real power seems to be incomposables. What are those?
- 14:53Speaker 2: Composables are reusable pieces of logic built with composition API functions.
- 14:58Speaker 2: Think of them as custom hooks like in React, but
- 15:01Speaker 2: for View.
- 15:02Speaker 1: So you extract stateful logic.
- 15:04Speaker 2: Into a function exactly like you could create a use
- 15:08Speaker 2: mouse position composable that tracks the mouse coordinates using ref internally.
- 15:12Speaker 1: And then reuse that use mouse position logic in any
- 15:16Speaker 1: component that needs it precisely.
- 15:18Speaker 2: It makes your code much more organized, reusable, and testable.
- 15:21Speaker 2: A use fetch composable for API calls is another classic.
- 15:24Speaker 1: Example that sounds powerful. Okay, shifting gears to more advanced
- 15:28Speaker 1: rendering render functions.
- 15:30Speaker 2: Right, we touched on this. Using the H function directly
- 15:33Speaker 2: to create vnodes gives you full programmatic control over the output.
- 15:37Speaker 2: Good for highly dynamic.
- 15:38Speaker 1: Stuff, and JSX is an alternative syntax for that.
- 15:40Speaker 2: Yeah, it's like writing HTML inside your JavaScript. Some people,
- 15:44Speaker 2: especially from a React background, prefer it over templates.
- 15:47Speaker 1: View supports it dynamic components.
- 15:49Speaker 2: What's the use case using component dot is component name variable.
- 15:53Speaker 2: You can switch which component gets rendered in a particular
- 15:55Speaker 2: spot just by changing the value of component name variable.
- 15:59Speaker 2: Think tabs or different views based on user.
- 16:01Speaker 1: Selection and plugins adding global stuff.
- 16:04Speaker 2: YEP plugins let you add global components, methods, or integrate
- 16:07Speaker 2: libraries like view router or Plena into your whole application
- 16:11Speaker 2: via app dot use Mike Luggins.
- 16:13Speaker 1: Speaking of view Router, that's for single page apps right
- 16:16Speaker 1: handling navigation exactly.
- 16:18Speaker 2: It's the official router. It maps URL paths to your
- 16:22Speaker 2: view components.
- 16:23Speaker 1: So about shows the about component, Users shows the user's component.
- 16:26Speaker 2: Pretty much. You define those mappings.
- 16:28Speaker 1: You use router view as the placeholder where the match
- 16:31Speaker 1: component appears.
- 16:32Speaker 2: Correct Router views where the content changes based on.
- 16:34Speaker 1: The URL, and Router link for a navigation instead of
- 16:37Speaker 1: regular autags.
- 16:38Speaker 2: Yes, routerlink to about creates the link and handles the
- 16:42Speaker 2: navigation without a full page reload. Keeps it feeling like
- 16:45Speaker 2: an app.
- 16:46Speaker 1: Does it handle dynamic parts in the URL like users
- 16:49Speaker 1: one two three, Oh.
- 16:50Speaker 2: Yeah, dynamic routes, users, dot ID, nested routes like having
- 16:55Speaker 2: subviews within a user profile, route guards for controlling access.
- 16:59Speaker 2: It's very cabable.
- 17:00Speaker 1: Okay. State management for data shared across many components. You
- 17:04Speaker 1: mentioned Pinia, Yes.
- 17:05Speaker 2: Pinia is the official recommended state management library, now replaced fux.
- 17:11Speaker 1: It uses stores right.
- 17:12Speaker 2: You define stores to hold specific pieces of your application state.
- 17:16Speaker 1: What's inside a store typically.
- 17:18Speaker 2: State, the actual data usually return from a function, getters
- 17:22Speaker 2: like computed properties for the store, and actions methods for
- 17:26Speaker 2: changing the state.
- 17:27Speaker 1: And it's built with the composition API in mind.
- 17:29Speaker 2: Very much. So you define stores with define store and
- 17:32Speaker 2: access them in components using a composable like function.
- 17:35Speaker 1: Conventionally use my store and something called store terrefs ah.
- 17:39Speaker 2: Yeah. If you want to destructure state properties or getters
- 17:42Speaker 2: from a store in your component, storage threats keeps them reactive,
- 17:46Speaker 2: Otherwise you might lose reactivity if you just pull them
- 17:48Speaker 2: out directly.
- 17:49Speaker 1: Got it. Styling components, how do you avoid CSS conflicts
- 17:52Speaker 1: between components?
- 17:54Speaker 2: The easiest way is style scoped. Just add the scope
- 17:56Speaker 2: attribute to your style tech.
- 17:58Speaker 1: And view automatically makes those styles only apply to that component.
- 18:01Speaker 2: Yep. Under the hood, it adds unique data attributes data
- 18:05Speaker 2: v something to your component's elements and scopes the CSS
- 18:09Speaker 2: selectors to match. Prevents styles leaking out or in what.
- 18:12Speaker 1: About CSS modules style module.
- 18:15Speaker 2: That's another scoping mechanism. It generates unique class names for
- 18:19Speaker 2: your styles like BUTTONBC one, two, three, and make them
- 18:22Speaker 2: available in your template via a special style object, so
- 18:25Speaker 2: you'd write dot class styled dot. My button class offers
- 18:29Speaker 2: very strong isolation.
- 18:30Speaker 1: Cool now making things look nice when they appear or disappear.
- 18:34Speaker 2: Transitions Yeah, view has built in support with the transition component.
- 18:38Speaker 1: You wrap the element you want to animate, like one
- 18:40Speaker 1: controlled by viv exactly.
- 18:42Speaker 2: Wrap the element or component in transition name fade.
- 18:45Speaker 1: And view adds CSS classes during the enter leave phases.
- 18:48Speaker 2: It does like fade in or from fade interactive, fade
- 18:51Speaker 2: inner two and corresponding leave classes. You define the actual
- 18:54Speaker 2: animation using CSS rules for these classes.
- 18:57Speaker 1: Can you customize the class names?
- 18:58Speaker 2: You can using props on transition and there are javascripts
- 19:02Speaker 2: hooks at before, enter, at enter, et cetera. If you
- 19:06Speaker 2: need more complex JS driven animations.
- 19:08Speaker 1: What about animating lists items added or removed from a
- 19:11Speaker 1: V four For.
- 19:12Speaker 2: That, you use transition group. It's similar, but designed specifically
- 19:15Speaker 2: for animating list elements, including move transitions when items are reordered.
- 19:20Speaker 2: Remember the dot key attribute is vital here too.
- 19:22Speaker 1: Right keys again. Okay. Testing, got to make sure things work.
- 19:25Speaker 1: Unit testing first, testing small pieces in isolation.
- 19:29Speaker 2: Yeah, testing individual components or composables, shaven highlights, vtist vitist
- 19:35Speaker 2: integrates well with v exactly. It's fast and modern. You
- 19:38Speaker 2: can figure it, invite dot config dot ts.
- 19:41Speaker 1: And you write tests using describe it expect standard.
- 19:44Speaker 2: Stuff, pretty standard testing syntax. Yes. A key thing in
- 19:48Speaker 2: unit tests is mocking dependencies like API calls. Vitis has
- 19:52Speaker 2: tools like via dots beyond for that.
- 19:54Speaker 1: How do you test composables, especially if they use life
- 19:56Speaker 1: cycle hooks?
- 19:57Speaker 2: Often you need a little helper setup maybe creating a
- 20:00Speaker 2: temporary component instance to mount the composable within its life cycle,
- 20:03Speaker 2: using something like.
- 20:04Speaker 1: With setup and the view test utels library helps with
- 20:07Speaker 1: interacting with components in tests.
- 20:09Speaker 2: Definitely, shall them ount or mount to render the component,
- 20:12Speaker 2: find the select elements triggered to simulate clicks or input
- 20:15Speaker 2: dot text that attributes to's the output to match snapshot.
- 20:19Speaker 1: For snapshot testing, Vitist has a UI too and code Coverage.
- 20:23Speaker 2: YEP, a graphical interface for running tests and tools like
- 20:26Speaker 2: at vitis coverage is dan bull to see how much
- 20:29Speaker 2: of your code is covered by tests. Good to aim
- 20:31Speaker 2: for decent coverage.
- 20:32Speaker 1: Okay, that's unit tests. What about testing the whole app
- 20:36Speaker 1: flow like a real user.
- 20:38Speaker 2: That's end to end or E two E testing. The
- 20:41Speaker 2: book introduces playwright for this.
- 20:42Speaker 1: Playwright automates browsers.
- 20:44Speaker 2: Right, you write scripts that tell Playwright and go to
- 20:46Speaker 2: this page, find this button, click it. Fill in this form,
- 20:49Speaker 2: check if this text.
- 20:50Speaker 1: Appeared, simulating the user journey exactly.
- 20:53Speaker 2: You locate elements using selectors, CSS, text data tested attributes
- 20:57Speaker 2: are good practice, and make consertions about the application state.
- 21:00Speaker 1: Does Playwright help with debugging?
- 21:02Speaker 2: Yeah? It has great debugging tools and produces nice hetmail
- 21:06Speaker 2: reports showing test results, screenshots, even videos.
- 21:09Speaker 1: Sometimes automating all this building, testing, deploying.
- 21:12Speaker 2: That's CICD continuous integration, continuous deployment. Yes. Chavin covers using
- 21:17Speaker 2: GitHub actions.
- 21:18Speaker 1: Getub actions, runs workflows defined in YAML files.
- 21:21Speaker 2: In your rebuff correct workflows have jobs, jobs, have steps, steps,
- 21:25Speaker 2: run actions or scripts. You set it up so when
- 21:28Speaker 2: you push code or open a poll request, it automatically builds,
- 21:32Speaker 2: runs tests, and.
- 21:33Speaker 1: Maybe deploys if everything passes. That's the goal, CDEs, Where
- 21:37Speaker 1: do you deploy chavin mentions? Netlphi.
- 21:40Speaker 2: Netlaphi is a popular choice for hosting modern web apps.
- 21:43Speaker 2: It integrates really well with kit providers like GitHub.
- 21:46Speaker 1: So Netlify can watch your repository and automatically deploy on
- 21:49Speaker 1: commits to Maine YEP.
- 21:51Speaker 2: It handles the build process, deploys to a global CDN,
- 21:54Speaker 2: gives you custom domains, hgtps build previews for poll requests.
- 21:58Speaker 2: Lots of features.
- 21:59Speaker 1: Okay, fine, A big topic. Server side rendering SSR and
- 22:02Speaker 1: Static side generation SSG. Why bother with these instead of
- 22:05Speaker 1: just client side rendering CSR.
- 22:07Speaker 2: Well, standard CSR where the browser downloads JavaScript and then
- 22:11Speaker 2: builds the page can sometimes be slow on initial load
- 22:14Speaker 2: users see a blank page for a bit, and it
- 22:17Speaker 2: could be trickier for SEO crawlers.
- 22:19Speaker 1: So SSR helps with that.
- 22:20Speaker 2: How With SSR, the server runs your view code, renders
- 22:23Speaker 2: the page to HTML, and sends that fully formed HTML
- 22:26Speaker 2: to the browser.
- 22:27Speaker 1: First, so the user sees content much faster and SEO
- 22:30Speaker 1: bots get HTML exactly.
- 22:32Speaker 2: The browser then hydrates the static HTML, making it interactive
- 22:36Speaker 2: by attaching the JavaScript event listeners.
- 22:38Speaker 1: In state and SSG. Static Site Generation.
- 22:40Speaker 2: SSG takes it further. It pre renders every page of
- 22:43Speaker 2: your site into static HTML files at build.
- 22:45Speaker 1: Time, so you just serve plane HTML files.
- 22:48Speaker 2: Basically, Yes, it's the fastest possible option and great for
- 22:51Speaker 2: SEO ideal for sites where content doesn't change super frequently,
- 22:54Speaker 2: like blogs or dogs.
- 22:55Speaker 1: Implementing SSR SSG in view sounds complex.
- 22:59Speaker 2: Though it can setting it up manually. That's why frameworks
- 23:02Speaker 2: like nets dot as exist.
- 23:03Speaker 1: Nextjs builds on top of view to simplify SSR and SSG.
- 23:07Speaker 2: Massively simplifies it. Next handles routing based on your file
- 23:11Speaker 2: structure in a page's directory, provides layouts built in data
- 23:14Speaker 2: fetching methods for server side. It makes building SSR ssgview
- 23:18Speaker 2: apps much more straightforward.
- 23:19Speaker 1: Wow, Okay, that was a lot. Let's try to recap
- 23:22Speaker 1: this deep dive.
- 23:23Speaker 2: Yeah, definitely. So fundamentally, viewjs is this progressive, really versatile
- 23:29Speaker 2: framework for modern web development.
- 23:31Speaker 1: It balances ease of use for getting started.
- 23:34Speaker 2: With really advanced features for building complex, production grade apps.
- 23:37Speaker 1: We went through setup, the performance boost from the virtual dome.
- 23:40Speaker 2: State management with Peona, routing with view router, testing strategies
- 23:45Speaker 2: with vetist and Playwright, deployment workflows.
- 23:48Speaker 1: And the whole ecosystem around it vite nextjs. It's a
- 23:51Speaker 1: comprehensive toolkit, it really is. And those aha moments, I
- 23:54Speaker 1: think the efficiency of the VDOM is one.
- 23:57Speaker 2: Definitely, and just the clarity you get from the options
- 23:59Speaker 2: API or the flexibility of the composition, API.
- 24:01Speaker 1: Composables for reuse.
- 24:03Speaker 2: This seems huge, absolutely, and just the overall streamline developer
- 24:07Speaker 2: experience the ecosystem provides.
- 24:09Speaker 1: Hopefully this has given you a solid foundation and maybe
- 24:11Speaker 1: spark some curiosity.
- 24:13Speaker 2: Yeah, you might be wondering, now, Okay, when exactly do
- 24:15Speaker 2: I use SSR versus SSG? Yeah? Or how do I
- 24:19Speaker 2: test really complex components or integrate View with my specific
- 24:23Speaker 2: back end?
- 24:24Speaker 1: Lots of avenues for deeper exploration, for sure.
- 24:26Speaker 2: The official docks for View Router, Pinia, nuxt. They're excellent
- 24:31Speaker 2: resources and the community is incredibly active and helpful.
- 24:35Speaker 1: So a final thought to leave you with. As web
- 24:37Speaker 1: development keeps evolving so rapidly, frameworks like View really shared
- 24:42Speaker 1: this constant push for better performance, the better developer experience, and.
- 24:46Speaker 2: Just more robust, scalable, and honestly more enjoyable web applications.
- 24:50Speaker 1: So how will these core ideas, component architecture, reactive, data,
- 24:54Speaker 1: efficient rendering, How will they continue to shape the future
- 24:57Speaker 1: of the web experiences we all use every day?
- 25:00Speaker 2: Something to think about, definitely something to think about.
- 25:02Speaker 1: Thanks for taking this deep dive with us,