Fork me on GitHub
#reagent
<
2018-07-10
>
kenny20:07:27

If I call reagent.core/track! like so:

(reagent/track!
  (fn []
    (let [x @(rf/subscribe [::my-sub])]
      (println "CHANGED --")
      (prn x))))
It only prints the change after a hot reload, not when the subscription changes. I can see in the re-frame-10x panel that ::my-sub is changing but my function passed to track! is not called. Any idea why?

danielcompton20:07:56

Do you need to create the sub on the outside?

danielcompton20:07:10

And deref it inside?

kenny20:07:25

Just tried that and still no function call on change.

kenny20:07:09

Interestingly, if I load the namespace in the REPL, the handler function gets called and the changed value is printed.

kenny20:07:48

The namespace is definitely required in the app though so not sure why loading the ns in the REPL changes anything.

fabrao20:07:21

hello all, how to I convert this

onHeaderRow={(column) => {
    return {
      onClick: () => {},        // click header row
    };
  }}
to clojurescript for using with reagent?

fabrao20:07:29

{(column) => {}} -> {:onHeaderRow (fn [column])} but return {onClick: ()=> {}} ?

mikerod20:07:13

@fabrao

{:onHeaderRow (fn [column] {:onClick (fn [])}))

mikerod20:07:52

not really assignment there, but if you had it in a map instead for the :onHeaderRow part

fabrao20:07:14

I don´t know, I think I´ll try jsx-to-clojurescript

fabrao20:07:45

jsx-to-clojurescript --kebab-tags "<Table onHeaderRow={(column) => { return {onClick: () => {}};}}/>" (ui/table {:onHeaderRow (fn [column] {:on-click (fn [])})})

fabrao20:07:49

you are righ

kenny20:07:16

It clearly has something to do with where track! is called. If I place the call inside of :component-did-mount , my callback function is called and the changes are printed.