---
title: "Discussion on \"Pinia listen state change example\" | Hashnode"
description: "Discussion on \"Pinia listen state change example\". Pinia\n\nexport const initData = function () {\n    const instance = useCounterStore()\n\n    // listen on change, then save to localStorage\n    instance.$subscribe((mutation, state) => {\n        localStorage.setItem(instance.$id, JSON.stringify(state)) \n..."
url: "https://hashnode.com/posts/pinia-listen-state-change-example/61b65c44b055806a4b00f73e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Pinia listen state change example](https://hn.0xbf.me/pinia-listen-state-change-example?utm_source=hashnode&utm_medium=feed)

Pinia export const initData = function () { const instance = useCounterStore() // listen on change, then save to localStorage instance.$subscribe((mutation, state) => { localStorage.setItem(instance.$id, JSON.stringify(state)) ...

Dec 12, 2021 · 1 min read · hn.0xbf.me  
Read the article

-   [#vuejs](https://hashnode.com/tag/vuejs)

## Written by

[0xBF](https://hashnode.com/@0xbf)

@0xbf

  
[View profile](https://hashnode.com/@0xbf)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
