cklmercer / vue-stash

Easily share reactive data between your Vue components.
MIT License
403 stars 29 forks source link

ripple effect of mutations #19

Closed coderofsalvation closed 7 years ago

coderofsalvation commented 7 years ago

is there a best practice with vue-stash for this:

  1. store variable 'products' (array)
  2. store variable 'shoppingbasket' (array)
  3. vue component 'shoppingbasket.vue'

i want the render the shoppingbasket component across several pages.

here it comes

However, if i delete a certain product from the product-array, and it happens to be in the basket, i want it to automatically get deleted from the basket too.

in vuex i guess a commit can trigger other commits too..how could one achieve this without hacking basket-management code in the products-delete-function.

cklmercer commented 7 years ago

vue-stash doesn't have any built-in mechanisms for handling these sort of things. In reality, you're vue-stash store is just an object that's saved on your root Vue component, so maybe a watcher would work?

coderofsalvation commented 7 years ago

ah yes, just a simple watcher would do magic. (I was thinking in vuex where component-watchers dont work on store variables) thx

On Tue, Aug 22, 2017 at 3:51 AM, Cody Mercer notifications@github.com wrote:

vue-stash doesn't have any built-in mechanisms for handling these sort of things. In reality, you're vue-stash store is just an object that's saved on your root Vue component, so maybe a watcher would work?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cklmercer/vue-stash/issues/19#issuecomment-323897089, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK_ZI6oFuOFtJMotL2LKuLyuZe7u4Cbks5sajQ9gaJpZM4O0_mV .

-- /WEBSITE 2wa.isvery.ninja /MOBILE +31 6 13499604 /LOCATION Netherlands, Drachten. Hongarije, Budapest. /COMPANYNR. 08124656 /TAGS Rapid Prototyping of ideas/concepts using JavaScript, Node.js, OpenSource. Growth-hacking partnerships, lead scraping partnerships.