Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can mutation.event return the full path of the changed value in the $subscribe callback #1782

Closed
Hansuku opened this issue Nov 8, 2022 · 1 comment

Comments

@Hansuku
Copy link

Hansuku commented Nov 8, 2022

What problem is this solving

A example:

import { defineStore } from 'pinia'

export const useFormData = defineStore('formData', {
  state: () => {
    return {
        arr: [{a:1}],
        obj: {a: 1}
    }
  }
})
import { useFormData } from '...'

export default {
  setup() {
    const formDataStore = useFormData()
    formDataStore.$subscribe((mutation, state) => {
       console.log(mutation, state)
    })
  },
}

now, if i change formData.arr[0].a = 2, mutation will callback mutation.event.key = 'a', but i want get full path like arr[0].a

Proposed solution

Can add an attribute to mutation.event to identify the direct's full path?

Describe alternatives you've considered

No response

@posva
Copy link
Member

posva commented Nov 8, 2022

events come from Vue: https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging

Note this is development only, it will be empty in production, it's only for debugging purposes

There are plans to make the display of it better in devtools already (See #732)

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants