Home > OS >  Vuejs intercomponent data exchange
Vuejs intercomponent data exchange

Time:09-08

I'am looking for a library/hook which I can use for loose-coupled data-exchange between related component. I could imagine something like this:

const { data, setData } = useStore('any.store-identifier')

I would expect data to be a ref which is updated if any component uses set setData function to update the structure. It is important that I do not have to predefine the stores. Any component which uses the same identifier will act on the same store which is created on first reference.

This is somehow a mix between vue-query and useState. Does anyone know if something like this is around or an other/better way to achieve this behavior? Of course I was googling before but I did really find something. Thank you for any hint!

Best regards, Dominic

CodePudding user response:

Hi for anyone who would do as Dominic and do not want to:

  • Have to predefine the data structure
  • Use specific method declared by any plugin or dependency
  • Be dependent of some structure or code base

You can use directly: Vue State Management Sharing reactive

And create your own state management system

Hope it will help other persons

  • Related