I would like to use simple react hook for rerender my component(instead of query) when reactive variable was changed.
For example useReactiveVariable(myReactiveVariable);
This would definitely be a worthwhile feature.
In terms of the implementation, I believe reactive variables would need to have a more general-purpose listener API. Right now updating a reactive variable calls cache.broadcastWatches() on any caches previously involved in reading the variable, but that behavior could be generalized/exposed via myVar.listen(newValue => {...}) or something similar.
@benjamn I am glad that you like this idea. Thank you
@seeden You can try this out in @apollo/[email protected] (released yesterday)!
// Either way works:
import { useReactiveVar } from "@apollo/client"
import { useReactiveVar } from "@apollo/client/react/hooks"
thanks @benjamn
Most helpful comment
@seeden You can try this out in
@apollo/[email protected](released yesterday)!