This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-15
Channels
- # beginners (15)
- # boot (4)
- # cider (1)
- # cljsrn (16)
- # clojars (1)
- # clojure (92)
- # clojure-india (3)
- # clojure-russia (27)
- # clojure-spec (9)
- # clojure-uk (5)
- # clojurescript (73)
- # cursive (28)
- # datascript (10)
- # emacs (1)
- # events (5)
- # hoplon (1)
- # instaparse (7)
- # juxt (2)
- # klipse (13)
- # lumo (17)
- # off-topic (166)
- # onyx (4)
- # protorepl (5)
- # re-frame (5)
- # reagent (13)
- # rum (26)
- # untangled (17)
- # yada (3)
@anton in rum, you can try using https://github.com/martinklepsch/derivatives
https://github.com/Otann/probe/blob/master/src/cljs/probe/components/spec.cljs#L47 https://github.com/Otann/probe/blob/master/src/cljs/probe/components/form.cljs#L9 etc.
@misha Yeah, this one is more descriptive I guess . https://github.com/martinklepsch/derivatives#comparisons
using < (d/rum-derivatives drv-spec)
on parent component instead of calling children with explicit arguments smells too funny for me
@misha derivatives are passed via React Context as you’ve probably seen. It’s a tradeoff to avoid having to always pass them down as an argument
@anton this might be interesting too: https://github.com/roman01la/scrum
@martinklepsch: I figured. On the other hand, if context is set just once at the top level, it might be okaish, need to give it a try
@misha yeah, idea is definitely that you only use the rum-derivatives
mixin once
you could use a top-level def alternatively, the API supports that but I don’t think that’s any better than using context. At least context is more easily swappable in tests etc.
Do changes to derived values propagate back to the original value/atom? Or is it just read-only cascade of derived atoms?
I am still not sure, but I think the problem was that because global state is a different object and components receive it in props, then all of them thinks they should re-render
@martinklepsch thank you! I think I ended up with something similar to scrum —https://github.com/Otann/probe/blob/master/src/cljs/probe/clux.cljs
@misha read only cascade, no upward propagation. I prefer the re-frame model of pushing events through a dispatcher.
@anton one important note on rum.core/derived-atom
: if you create them programatically they will not “clean up after themselves”. Each derived atom adds watches on it’s source atoms. As long as you defonce
those it’s fine but if you don’t you’ll end up computing the same things many times due to duplicate watches.
@martinklepsch I understand that, and glad that you confirmed my thoughts
I tried same project with reagent and re-frame and for me it very quick became messy =/
too many abstractions — 3 types of components, subscriptions, handles, effects. My biggest concern was very tight coupling between components/handlers/subscriptions, while having code in three different locations
@misha yes, it saved the day in the end. problem was that the state prop was a global state, so < r/static
could not do much before
@martinklepsch I read a readme of SCRUM, what do you think about passing reconciler around the compoents tree?
I also found couple of things troubling:
- component name is a plain keyword, which tightly couples controller UI component to reconciler definition. Meaning in following code: [:button {:on-click #(scrum/dispatch! r :counter :dec)} "-"]
you have to attentively keep track of the controller :counter
name. I tried namespaced keywords, but could not get it working
- when defining a reconciler you have to manually list all components. I think this is a way to avoid global reconciler, but I don't mind having a global one