Hi!
I would like to use reactive vars to handle my global local state in my app. One thing I can’t seem to figure out is how to react to a variable change when I’m outside of a component. Basically I want to do simple stuff like: When this value is updated, run that function to save the new value to a localStorage. I wan tthis reaction to be handled outside of the component because I don’t want it to be linked to a specific component. Whenever this var gets updated from anywhere in the app, I want to react to the change and do some stuff.
I tried putting the stuff I want to run in
typePolicies: {
Query: {
fields: {
something: {
merge: (_, incoming) => {
// Run some custom function
return incoming
},
},
},
},
},
and then updateing the reactive var using somethingVar(newValue)
, but it doesn’t feel like the correct thing to do and the ‘merged’ is not getting called anyway.
Thanks!