helix

https://github.com/Lokeh/helix
2021-05-23T17:46:09.015200Z

I’m struggling to make re-frame work with Helix. The subscription works, but the dispatch and / or reloading the component when the event is triggered doesn’t seem to be working. Here’s the code, can anyone figure out what I’m doing wrong?

(defnc TabA [_] {:helix/features {:fast-refresh true}}
       ($ rn/View {:style (j/lit {:flex 1, :alignItems "center", :justifyContent "center"})}
          ($ rn/Text {:style (j/lit {:fontSize 36})}
             (str "clicked " @(rf/subscribe [:get-counter])))
          ($ rn/TouchableOpacity {:style    (:button styles)
                                  :on-press #(rf/dispatch [:inc-counter])}
             ($ rn/Text {:style (j/lit {:fontSize 36})} "Click here"))))

jimmy 2021-05-23T18:19:49.015300Z

As far as I know, reframe is very specifically tied to reagent and you will have a really hard time using it with anything else.

jimmy 2021-05-23T18:21:15.015500Z

Actually, there is a guide on this though. https://cljdoc.org/d/lilactown/helix/0.0.13/doc/integrating-with-other-libraries

jimmy 2021-05-23T18:22:41.015800Z

Looks like not fully fleshed out. But gives an idea on what will be required. Some sort of custom hook to subscribe to the r/atom. If you are not super experienced with this stuff, I'd personally recommend against the combination unless this is just a for fun project 🙂

2021-05-23T20:01:42.016600Z

Thanks - will look into that guide (even though it does look incomplete).

2021-05-23T20:31:27.016800Z

here is a example of a hook to solve the problem: https://github.com/lilactown/hooks-demo/blob/master/src/hooks_demo/hooks.cljs#L41

2021-05-23T21:21:52.017100Z

oh, awesome - will try that. Thanks!