cklmercer / vue-stash

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

Reset store to intial state #18

Closed mkelley82 closed 7 years ago

mkelley82 commented 7 years ago

How would you go about resetting the store to the initial state (intial state declared in separate files and imported)... without manually resetting all the properties of the state?

ozeebee commented 7 years ago

Hi, I had the same requirement. I simply cloned the initial store and saved it in a variable. Then I added a method on the store itself to "restore" the initial state based on the saved state.

mkelley82 commented 7 years ago

That's what i ended up with as well. Thanks for sharing.

cklmercer commented 7 years ago

ozeebee has the recommended solution! Thanks guys! glad you figured it out :)