-
Notifications
You must be signed in to change notification settings - Fork 0
Vue Connect Tech 2019
Yongku cho edited this page Feb 24, 2020
·
8 revisions
- Portable functionality
- Composable abstractions
- Explicit extraction of logic, including stateful logic
- Feature based organization vs. Option-based organization
https://www.vuemastery.com/conferences/connect-tech-2019/managing-state-in-vuejs
- Store Model for State
- Reduces the paths where data is mutated
- Introduces more concepts (complexity)
Vue Components =[Dispatch]=> Actions =[Commit]=>
Mutations =[Mutate]=> State =[Render]=> Vue Components
Vue 컴포넌트의 상태관리는 Vuex를 통해서 한다.
https://www.vuemastery.com/conferences/connect-tech-2019/fundamental-component-design-patterns/
- New requirements increase complexity
- Multiple responsibilities
- Lots of conditionals in the template
- Low flexibility
- Hard to maintain
- Content distribution (like layouts)
- Creating larger components by combining smaller components
- Default content in Multi-page Apps
- Providing a wrapper for other components
- Replace default component fragments
- Applying custom formatting/template to fragments of a component
- Creating wrapper components
- Exposing its own data and methods to child components
- Slots: With composition, you're less restricted by what you are building at first.
- Props: With configuration, you have to document everything and new requirements means new configuration
Examples: UserProfile, Product, TheShoppingCart, Login
- Application logic
- Application state
- Use Vuex
- Usually Router views
Examples: AppButton, AppModal, TheSidebar, ProductCard
- Application UI and styles
- UI-related state only
- Receive data from props
- Emit events to containers
- Reusable and composable
- Not relying on global state
Props를 통한 컴포넌트 디자인은 복잡하다. Slot을 통해 해결할 수 있다.
Scoped slots을 사용하면 자식 컴포넌트에 전달한 상태를 부모에서 사용할 수있다. 반복에 대한 처리를 자식에서 하고 부모는 어떤 것을 표시할지 선택할 수 있다.
마지막장쯤에는 언제 리팩토링이 필요한가에 대한 내용도 다룬다.