Learn Vue JS course Learn Javascript and Vue JS Learn VueJS course Learn VueJS Tutorial

Vue 3 Composition API

Use Shared State Between Uses of a Composable thumbnail image

Get access to the most comprehensive Vue.js video library in the world. Over 300 video lessons including the newest Vue 3 features.

Use Shared State Between Uses of a Composable

In this lesson, we learn how to share state between multiple uses of a composable. We use this knowledge to create a one off loading indicator at the top level of our application for every page, as well as an error handler for reporting failed requests to the user.

NOTE: This lesson does include a bug (a race condition) in it's implementation. It does NOT however affect the concept taught. Sharing state between multiple uses of a composable as shown in the video is a legitimate practice. If you'd like more info on the race condition and the issue it causes checkout this blog post for more info.