2024-02-24
4517
#vue
Ivaylo Gerchev
102924
Feb 24, 2024 â‹… 16 min read

Leveraging Pinia to simplify complex Vue state management

Ivaylo Gerchev All things are difficult before they are easy.

Recent posts:

Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 min read
JavaScript logo on top of violet background

Exploring essential DOM methods for frontend development

Learn four groups of DOM methods and their uses to create responsive and dynamic webpages. A helpful DOM reference table is also included.

Chimezie Innocent
Jul 23, 2024 â‹… 12 min read
View all posts

17 Replies to "Leveraging Pinia to simplify complex Vue state management"

  1. I am really happy with your tutorial and about your patient to write details. It’s really helpful for us. Please write this type of article further.

  2. Thanks for the tutorial. This lines concern me – is it good practice to save the password unencrypted in the localStorage?

    user.authdata = window.btoa(username + ':' + password);

    ...

    // store user details and basic auth data in local storage to keep user logged in between page refreshes

    localStorage.setItem('user', JSON.stringify(user));

  3. I have problem with PostView.vue. fetchPost(to.params.id) is call only when i refresh page or first load, but when i click on any link with /post/:id never fire fetchPost(to.params.id) and get new post. When i change PostView.vue in script setup to:

    onBeforeRouteUpdate(async (to, from) => {
    if (to.params.id !== from.params.id) {
    fetchPost(to.params.id)
    }
    })

    Its OK. Where is problem?

    THX

  4. But the problem with this approach is that, imagine you want to access the posts state in multiple components, then you’d have to call the fetch function from pinia store in all these components (which is not DRY). We want a way to fetch the data directly from the store once it is created and before any component using it mounted or even created.

Leave a Reply