helix

https://github.com/Lokeh/helix
y.khmelevskii 2020-03-21T22:13:22.208Z

Just curious what is the difference between these examples:

(helix/defhook use-connect []
  (hooks/use-effect
   :once
   (js/console.log "Test")))
and
(defn use-connect []
  (hooks/use-effect
   :once
   (js/console.log "Test")))

lilactown 2020-03-21T22:31:29.208300Z

at the moment, nothing

lilactown 2020-03-21T22:34:32.211100Z

the goal is to add some functionality on top of defn to provide things like: • compile-time warning when breaking the “Rules of Hooks” • compile-time inference of dependencies for optimizations like use-memo and use-callback • adding metadata about arguments so that defnc can detect when dependencies haven’t been filled in for your custom hook

lilactown 2020-03-21T22:34:58.211600Z

oh, and integration with react-refresh so that your custom hooks will refresh appropriately

lilactown 2020-03-21T22:35:36.212100Z

all of these are compile time devtooling. at runtime, it will act the same as a defn 🙂 hope that helps!

👍 1
❤️ 2
y.khmelevskii 2020-03-21T22:46:28.212600Z

Great. Thank you for detailed explanation!