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:

CSS typography in white on a vibrant red geometric background. Article will focus on the CSS backdrop-filter property and its various functions, including blur, grayscale, brightness, and drop-shadow.

How to use the CSS backdrop-filter property

Backdrop and background have similar meanings, as they both refer to the area behind something. The main difference is that […]

Oscar Jite-Orimiono
Oct 4, 2024 â‹… 10 min read
6 AI Tools For API Testing And Development

6 AI tools for API testing and development

AI tools like IBM API Connect and Postbot can streamline writing and executing API tests and guard against AI hallucinations or other complications.

Frank Joseph
Oct 3, 2024 â‹… 12 min read
Patterns For Efficient DOM Manipulation With Vanilla JavaScript

Patterns for efficient DOM manipulation with vanilla JavaScript

Explore DOM manipulation patterns in JavaScript, such as choosing the right querySelector, caching elements, improving event handling, and more.

Joe Attardi
Oct 2, 2024 â‹… 8 min read
Integrating Chrome's New `Window.ai` API In A Vue App

Integrating AI features in Vue using Chrome’s `window.ai` API

`window.ai` integrates AI capabilities directly into the browser for more sophisticated client-side functionality without relying heavily on server-side processing.

Emmanuel John
Oct 1, 2024 â‹… 10 min read
View all posts

18 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