vuejs / pinia

🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support
https://pinia.vuejs.org
MIT License
12.72k stars 996 forks source link

【$subscribe】When the state is an Array, "mutation.events.key" doesn't indicate the state's name. #2679

Closed Fukao0129 closed 1 month ago

Fukao0129 commented 1 month ago

Reproduction

https://play.pinia.vuejs.org/#eNqNVFFv2jAQ/itWNKkgFXtVp05iUNFNfegetmnsbd6DSQ4wJLZlOxSE+O872ySEjVblgTj5vvt8953P++zBGLqpIRtmI5dbaTxx4GtDSqEWY555x7N7rmRltPVkT2oHU68tkAOZW12RK8pyXSsPlnp3xRVXuVYORSJp3PJ7/QYR1oodIr0+Gd/vuSL4i2yKGz8EcOqFhx7PCuEFzzDwcFK1Ui1eCp5G9FI0x+BAeufqWahyBj3hdionvapGutTqGmUwLsiSo64owfqWQGEDyju6hl3Q7H/iasSSY+gPvnioTIkS+EbIaFZ7rxWZ5KXM1+hjrBqtjM8RS/BlaioSuWnRIY9YZ5PsOktdGVTC0JXTCnsYU+dHAFs3bIrhmZFKoiFDXLK4puCqwczqZ4fNWyH5uqFO8ECwAjZe69INhJEpbOm9cUPG8kIhv4BSbixV4JkyFfsvZnJH7+gNK+WM4UZMqgK259tgxKCA6i3qDXXynt58oB+j6ub2KFoF1SCKnT6gLd7haZnLxT+m5LoyEnv63YR+npsjylI/f43fvK2hTTFfQr6+8H3ltinrHxbQvg10yvLCLsAn+HH6Dba4bsFKF3WJ7FfAn+B0WYccE+1zrQpMu8OL2T7FHuMB+eUetx6Ua4oKiUY3Ij/a/OWV0k/p3tLbjounsUYL2/kvYC7V+RXQHi0cCa5gG5lpXtvbYtwNxOGM4/hUYE0pkTh8wzTWpNcMYJiVIfn951h4modgydGLQz8+RB6rams6v0eM2JVaFP0GJcQvpaNRnJraLVtGwpNtUaV7obwg095IIanLyDGyqx7+4xWSHf4CusDYMQ==

Steps to reproduce the bug

Click the 【array】button.

Expected behavior

I'm sure that "mutation.events.key" indicate the name of the state. By clicking the 【array】button, the "array" state is updated. Thus "mutation.events.key" must be "array".

Actual behavior

"mutation.events.key" is "0".

When the state is a String, "mutation.events.key" indicates the name of the state without issue.

Additional information

No response

posva commented 1 month ago

This is expected and it comes from vue core. The actual key changing is the index of the pushed value

Fukao0129 commented 1 month ago

I got it, thank you.