buhrmi / vue-sync

Vue plugin that syncs state with URL params
https://buhrmi.github.io/vue-sync
64 stars 2 forks source link

[suggestion] Synchronizing entire vue data object #1

Closed dariuszsikorski closed 8 years ago

dariuszsikorski commented 8 years ago

Hello, first of all, thanks for providing entire vue-sync lib, it's simplicity looks very promissing!

From the documentation, synchronization can be attached to vue data properties. What if you would watch entire data object for changes and keep it synchronized? it would look like that:

new Vue({
  data: {
    theme: 'light',
    user: {...},
    cart: {...}
  },
  sync: {
    data: localStorageSync('app data');
  }
})

It's just a concept, but may be worth considering. By the way i keep the fingers crossed for localStorage strategy since it seem to be great solution for single page applications oppened in multiple tabs.

Regards

buhrmi commented 8 years ago

Hi

thanks for the suggestion. Should be easy to implement. Will probably find some time to work on it the coming days.

Cheers

buhrmi commented 8 years ago

added the localStorage strategy to sync data between tabs and restore the state after reloading the page. However, i dont think that syncing the entire "data" makes sense. Just attach synchronization to all keys that are important.

dariuszsikorski commented 8 years ago

Thanks, that was fast. Adding localStorage is good news as well :)