XantreDev / preact-signals

Preact Signals: Supercharge your React/Preact development! Unleash the power of reactive programming with hooks, components, a TanStack query adapter, and more. Code smarter, not harder
https://preact-signals.netlify.app/#/
MIT License
64 stars 0 forks source link

Question: Passing signal to enabled #181

Closed Munawwar closed 1 month ago

Munawwar commented 1 month ago

Hi, first off nice project! 🚀

Question: Shouldn't enabled take the signal and not signal.value in the readme example?

const query = useQuery$(() => ({
  queryKey: ["user"],
  queryFn: () => fetchUser(),
  enabled: isUserRegistered.value, // <-- this part
}));
XantreDev commented 1 month ago

useQuery$ takes callback as an argument - so it will subscribe to any signal reads inside of the callback

Munawwar commented 1 month ago

Right! I get it now. Thanks.