Fork me on GitHub
#rum
<
2017-04-15
>
mikeb00:04:04

Are there any examples of rum used with routing such as funcool/bide?

misha04:04:52

@anton try to add < rum/static

misha04:04:46

@nxqd I should have read that, thanks.

misha04:04:29

using < (d/rum-derivatives drv-spec) on parent component instead of calling children with explicit arguments smells too funny for me harold

martinklepsch08:04:37

@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

misha10:04:31

@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

martinklepsch10:04:02

@misha yeah, idea is definitely that you only use the rum-derivatives mixin once

martinklepsch10:04:52

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.

misha10:04:02

Do changes to derived values propagate back to the original value/atom? Or is it just read-only cascade of derived atoms?

anton10:04:06

thank you guys! I tried derived-atom and it speeded up everything

anton10:04:12

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

anton10:04:52

@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

martinklepsch10:04:51

@misha read only cascade, no upward propagation. I prefer the re-frame model of pushing events through a dispatcher.

martinklepsch10:04:43

@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.

anton10:04:36

@martinklepsch I understand that, and glad that you confirmed my thoughts

anton10:04:13

I tried same project with reagent and re-frame and for me it very quick became messy =/

anton10:04:16

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

anton11:04:50

@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

anton11:04:11

@martinklepsch I read a readme of SCRUM, what do you think about passing reconciler around the compoents tree?

anton12:04:10

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