This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-02
Channels
- # beginners (118)
- # boot (73)
- # cider (2)
- # cljs-dev (65)
- # cljsrn (18)
- # clojure (49)
- # clojure-argentina (4)
- # clojure-italy (19)
- # clojure-portugal (1)
- # clojure-russia (1)
- # clojure-spec (34)
- # clojure-uk (102)
- # clojurescript (202)
- # code-reviews (3)
- # core-async (5)
- # cursive (11)
- # datomic (25)
- # emacs (1)
- # graphql (22)
- # hoplon (6)
- # keechma (59)
- # leiningen (10)
- # luminus (31)
- # lumo (78)
- # off-topic (141)
- # om (32)
- # om-next (2)
- # onyx (6)
- # parinfer (55)
- # pedestal (3)
- # protorepl (3)
- # re-frame (8)
- # reagent (8)
- # ring-swagger (1)
- # rum (20)
- # specter (1)
- # sql (5)
- # test-check (11)
- # vim (13)
- # yada (7)
@escherize it's in :rum/args
. Oh wait. let me double check
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
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. 🙂
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)])
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)))
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
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.
@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.
Here's a fix for the readme then: https://github.com/tonsky/rum/pull/147