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:

How To Create Heatmaps In Javascript: Exploring The Heat Js Library

How to create heatmaps in JavaScript: The Heat.js library

This tutorial will explore the application of heatmaps in JavaScript projects, focusing on how to use the Heat.js library to generate them.

Oghenetega Denedo
May 8, 2024 â‹… 7 min read
Eleventy Adoption Guide: Overview, Examples, And Alternatives

Eleventy adoption guide: Overview, examples, and alternatives

Eleventy (11ty) is a compelling solution for developers seeking a straightforward, performance-oriented approach to static site generation.

Nelson Michael
May 7, 2024 â‹… 8 min read
6 CSS Tools For More Efficient And Flexible CSS Handling

6 CSS tools for more efficient and flexible CSS handling

Explore some CSS tools that offer the perfect blend of efficiency and flexibility when handling CSS, such as styled-components and Emotion.

Fimber Elemuwa
May 7, 2024 â‹… 7 min read
Leveraging React Server Components In Redwoodjs

Leveraging React Server Components in RedwoodJS

RedwoodJS announced support for server-side rendering and RSCs in its Bighorn release. Explore this feature for when it’s production-ready.

Stephan Miller
May 6, 2024 â‹… 9 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