Fork me on GitHub
#re-frame
<
2017-01-17
>
stuartrexking00:01:30

@brthrjon You can put them wherever you want. We tend to group our handlers, events, subs and views in a namespace based on functionality. Our event stuff goes into an events.cljs within each namespace, so that’s where we put reg-fx's

stuartrexking00:01:19

@brthrjon Be aware you need to load any namespaces that have a reg-fx from your entry point / main so that the events get registered.

brthrjon02:01:58

I know that aget has a method for getting nested properties like:

brthrjon02:01:59

(aget js/object "prop1" "prop2" "prop3") ;; JS output: object["prop1"]["prop2"]["prop3"];

brthrjon02:01:39

it doesn't look like aset has anything analagous... anybody got a nifty way to do that?

stuartrexking02:01:17

I think assoc-in is what you want.

brthrjon02:01:26

ahh... of course.

brthrjon04:01:03

@stuartrexking couldn't get that to work, tried to use property names as strings but didn't work... eventually settled on (set! (-> obj .-field1 .-field2) value)

stuartrexking04:01:17

Ok. I don’t know about the js syntax for doing that, but if it was a clojure map I would do assoc-in

dviramontes05:01:44

@curlyfry thanks for the pointers 🙂

minikomi05:01:23

Alternatively, (set! (.. obj -field1 -field2) value) should also work

brthrjon19:01:01

@minikomi @stuartrexking I was actually disappointed that assoc-in doesn't work. That's what it does, sets a value in a nested structure given the path of keys. However, what I'm doing is mutating, which makes assoc-in inappropriate. Thanks for both of you for your input.