Category · 8 articles

Composables

Articles in the category Composables.

Vue Tip: When You Should Use a Composable Image

Vue Tip: When You Should Use a Composable

Vue composables are a way to encapsulate logic in a reusable way in Vue 3. They are a great way to share logic between components, but I often see them used in places where they are not needed.
Vue Tip: Composable to Define Keyboard Shortcuts Image

Vue Tip: Composable to Define Keyboard Shortcuts

I show you a handy Vue composable that allows you to define keyboard shortcuts in your app.
Vue Tip: Use Your Composables Synchronously Image

Vue Tip: Use Your Composables Synchronously

You should always call your composables synchronously in setup() hook or <script setup>. Otherwise Vue will not be able to determine the current active component instance and cannot correctly register features like lifecycle hooks, watchers, and computed properties.
Vue Tip: Simple State Management With Composition API Image

Vue Tip: Simple State Management With Composition API

Learn how you can use Composition API for a simple state management solution which you can use instead of Pinia.
Vue Tip: Dynamic Return Values in Composables Image

Vue Tip: Dynamic Return Values in Composables

FIXME
Vue Tip: Use VueUse to Unleash the Power of Utility Functions Image

Vue Tip: Use VueUse to Unleash the Power of Utility Functions

VueUse is a collection of hundreds of essential Vue Composition Utilities for interacting with various browsers, sensors, animations, and state APIs, and more.
Vue Tip: Emit Event From Composable Image

Vue Tip: Emit Event From Composable

Your application may contain a lot of components that are using the same logic, like emitting the same event. In this case, it might be tempting to create a composable that will emit this event and is used in all components. But how do you emit an event from inside a composable?
Vue Tip: Share Composable State Across Components Image

Vue Tip: Share Composable State Across Components

It is possible to sync composable state across components by lifting its definition outside the exported function.