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:

Integrating Django Templates With React For Dynamic Webpages

Integrating Django templates with React for dynamic webpages

Create a dynamic demo blog site using Django and React to demonstrate Django’s server-side functionalities and React’s interactive UI.

Kayode Adeniyi
Apr 18, 2024 â‹… 7 min read
Using Aoi Js To Build A Bot For Discord

Using aoi.js to build a bot on Discord

Explore how the aoi.js library makes it easy to create Discord bots with useful functionalities for frontend applications.

Rahul Padalkar
Apr 17, 2024 â‹… 9 min read
Web Components Adoption Guide: Overview, Examples, And Alternatives

Web Components adoption guide: Overview, examples, and alternatives

Evaluate Web Components, a set of standards that allow you to create custom HTML tags for more reusable, manageable code.

Elijah Asaolu
Apr 16, 2024 â‹… 11 min read
Using Aws Lambda And Aws Cloudfront To Optimize Image Handling

Using AWS Lambda and CloudFront to optimize image handling

Leverage services like AWS Lambda, CloudFront, and S3 to handle images more effectively, optimizing performance and providing a better UX.

Nitish Sharma
Apr 12, 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