rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
escherize 2017-08-02T06:28:37.693341Z

Hi, I'm following along with the readme. Do I have a typo here?

jimmy 2017-08-02T06:40:30.857918Z

@escherize it's in :rum/args. Oh wait. let me double check

escherize 2017-08-02T06:42:30.885829Z

Oh, I see. Is that a typo in the README then?

jimmy 2017-08-02T06:43:18.897233Z

hmm, no, it's actually in state, only props is in :rum/args

escherize 2017-08-02T06:48:33.974285Z

I expected it to be in state. It doesn't seem to be there though.

jimmy 2017-08-02T06:48:39.975661Z

ok I got it, you forgot to add watch on the component. If you want to change the state manually like above, you need to have add-watch

escherize 2017-08-02T06:50:07.997386Z

Not sure I understand. add-watch works on atoms, but I'm not using any atoms here am I? Apologies if question is odd - I'm new to rum. 🙂

jimmy 2017-08-02T06:51:09.012301Z

for sure, I will send you a source code from rum. It explains things better.

escherize 2017-08-02T06:52:18.029117Z

How would you change this to actually work? I coppied this code from the readme, so once it's fixed I can make a PR to fix it

(rum/defcs time-label < { :did-mount (fn [state]
                                       (assoc state ::time (js/Date.))) }
  [state label]
  [:div label ": " (::time state)])

jimmy 2017-08-02T06:54:43.065205Z

yeah, I haven't read the part closely. However, if you check this example:

(rum/defcs component < rum/static 
                       rum/reactive
                       (rum/local 0 ::count)
                       (rum/local "" ::text)
  [state label]
  (prn (keys state)))

jimmy 2017-08-02T06:54:54.067801Z

you should see ::count and ::text

escherize 2017-08-02T06:56:03.086032Z

Yep, I see them.

escherize 2017-08-02T06:56:30.093273Z

looks like that.. anonymous mixin isn't working as expected, ey?

jimmy 2017-08-02T06:56:38.095060Z

then let's get back to your initial example: this is how rum/local works: https://github.com/tonsky/rum/blob/gh-pages/src/rum/core.cljs#L242-L255

jimmy 2017-08-02T06:57:26.107736Z

basically, it creates an atom and then add-watch on that atom to rerender the component. You have to do the same for your init example. basically, the ::time is there in state but the component is not re rendered so you don't see it.

rauh 2017-08-02T06:59:08.133342Z

@escherize did-mount only runs AFTER your initial render. That's why you don't see the key in there. Change it to will-mount if you want.

👍 1
escherize 2017-08-02T06:59:37.141094Z

Ah, yes. :will-mount fixed it.

escherize 2017-08-02T07:08:25.288521Z

Here's a fix for the readme then: https://github.com/tonsky/rum/pull/147

👍 1
escherize 2017-08-02T07:11:45.344147Z

Thanks for ur help you guys. 👌:skin-tone-3: