Fork me on GitHub
#re-frame
<
2016-03-28
>
gadfly36116:03:05

@hoopes @afhammad an alternative to manually namespacing keys would be to use a double colon, e.g. ::foo

hoopes16:03:54

what does that buy you? you mean something like :panel1::foo ?

gadfly36116:03:22

No, like ::foo and drop the panel1 portion

gadfly36116:03:35

Assuming youre in a panel1 namespace

gadfly36116:03:39

Say youre in a namespace app.panel1 and you make a key ::foo in that namespace. If you require that namespace somewhere else, you can alias it like [app.panel1 :as panel1] ... then you can access that foo key by doing :panel1/foo

gadfly36116:03:38

Its a way to use actual namespaces as opposed to mocking them with keynames by convention

hoopes16:03:57

got it - had to learn what the double colons are for real quick simple_smile even better than the slash, thanks a lot!

afhammad17:03:50

@gadfly361: Interesting, thanks

josesanch18:03:24

Hello, I've a problem and I don't know how to solve. What is the correct way of doing this

josesanch18:03:27

(defn servicio-tiempo [servicio] (reagent/with-let [gruas (subscribe [:servicio->gruas servicio]) rutas (subscribe [:servicio->rutas servicio]) servicios [servicio]] [:div [map-component {:gruas @gruas :rutas @rutas :servicios servicios :autofit true :style {:height "450px"}}] ] ))

josesanch18:03:39

I'm using a subscription, but I'm passing a parameter to it. This is not making the component to change when the parameter servicio is changed

josesanch18:03:13

Evaluating the value every time the component is rendered obviously works correctly

josesanch18:03:04

But, I wanted the subscription to be reactive. Is that possible? Or I'm doing just wrong?

afhammad18:03:09

@josesanch: is servicio an atom/ratom?

afhammad18:03:08

if so then I don’t believe it will trigger a re-render when its value changes (unless you deref it) since it will be compared using identical? rather than =. You can read more about that here: https://github.com/Day8/re-frame/wiki/When-do-components-update%3F#changed

nidu18:03:43

@josesanch: if servicio can change without component recreation, than you probably need dynamic subscriptions https://github.com/Day8/re-frame/wiki/Dynamic-Subscriptions

josh.freckleton21:03:06

@escherize: Awesome advice, but as I've been trying to implement it I've been encountering a problem. Namely, when I try to have an input with a value, and an on-change, I can't change the value anymore, ex:

[:input {:type "password"
                 :name "password"
                 :placeholder "Password"
                 :value @password
                 :on-change #(dispatch [:update-login-form
                                        :password
                                        (-> % .-target .-value)])}]
any idea wht I'm doing wrong?

josh.freckleton21:03:39

the dispatch works just fine, but the value isn't updating...

nberger22:03:25

@josh.freckleton try with :default-value instead of value

josh.freckleton22:03:34

@nberger: hm, that mostly works! When I dissoc though, the inputs don't update to being empty, which I think I'm subscribing to, any idea why not?

josh.freckleton22:03:56

well, no subscriptions are working in these inputs?!

josh.freckleton22:03:50

even though the ratom changes, the changes don't propagate to :default-value @password, but they do exist in the db...

nberger22:03:09

Oh, that's the thing with default value though... It takes the value on mount, then doesn't update on external changes... You are dissocing in the handler?

nberger22:03:33

The input in re-com handles the two kind of updates... Internal and external... You could use it, or see the code and use the same strategy

josh.freckleton22:03:40

whew, just looked the code over here: https://github.com/Day8/re-com/blob/master/src/re_com/misc.cljs a bit heavy for me, I'll try to avoid needing this for now, until I'm a better clj guru simple_smile

tom23:03:17

I may be thinking too hard about this one... Are there any examples for handling animations (e.g., toggling a class on a sibling element) when using re-com layout (v-box, h-box, box, etc)?

josh.freckleton23:03:23

@tom I've had success using garden https://github.com/noprompt/garden for toggling/tweaking css stuff. Have you considered that lib?