cklmercer / vue-stash

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

How to add hook for sets #8

Closed xhh2a closed 7 years ago

xhh2a commented 7 years ago

First off, a big thanks for making this library. Really solves the simple use cases I want.

I would like to save to localStorage (debounced) every time something is updated (set is called). Do you have any insights on the best way to do so while using vue-stash? I'm not sure how I would go about extending/overriding the set() function in store-accessor.js after I import vue-stash and tell Vue to use it. Or would it require changing the file itself prior to importing and making a fork?

Thanks!

xhh2a commented 7 years ago

Nevermind I figured out how to do this using a global mixin method and having that handle all state updates.

Leomund commented 7 years ago

@xhh2a Hello. I have same case. Would you share your solution?

Leomund commented 7 years ago

@xhh2a I solved it with adding vue watcher on store in my App.vue component. But i still interested to see your solution.