Fork me on GitHub
#beginners
<
2016-08-22
>
shooodooken14:08:54

is there a cleaner way to accomplish the below so that I end up with the same result? i.e.

{:parent-key {:other-child {}, :child-key {:child-data {}}}}
(update-in {:parent-key {:other-child {}}} [:parent-key :child-key] (constantly (:child-key {:child-key {:child-data {}}})))

josh_tackett14:08:39

@shooodooken elaborate a bit on what you’re trying to do

shooodooken14:08:06

associate the 'child-key structure in under the parent-key structure without affecting 'other-child'

shooodooken14:08:55

(assoc-in {:parent-key {:other-child {}}} [:parent-key :child-key] {:child-data {}})

shooodooken14:08:12

is the cleanest i can get?

shooodooken14:08:42

in real life, child-key & child-date are a single variable passed in so I was hoping to nest the structure without having to explicitly state the child-key in the assoc-in or update-in

josh_tackett14:08:40

what should the result look like?

josh_tackett14:08:47

and you post result data structure?

shooodooken14:08:27

result should look like this

{:parent-key {:other-child {}, :child-key {:child-data {}}}}

jmelton14:08:55

I’m trying to figure out how to do a simple http get request from frontend clojurescript. I need to hit an external rest api endpoint and get the json back. That’s all.

josh_tackett15:08:28

Yep that looks clean with the assoc-in @shooodooken

josh_tackett15:08:59

That should do it

jmelton15:08:04

@josh_tackett I tried using it but I can’t figure out what to put in my project.clj deps. This is the first time I’m trying to use clojurescript at all.

mss19:08:01

this is more of a java interop question, but is there anything special you need to do to import an interface in an ns declaration?

mss19:08:15

I’m trying to reify an interface, but can’t seem to import it correctly

mss19:08:37

packageName.interfaceName and packageName$interfaceName both don’t seem to work

mss19:08:45

if that’s the idiomatic way to do that, though, then I must be doing something wrong

jeff.engebretsen19:08:01

Note that nested class is referred via '$' (reify java.lang.Thread$UncaughtExceptionHandler …

jeff.engebretsen19:08:42

Is it an interface from Java land?

jeff.engebretsen19:08:13

In the ns, I think you just import the interface/parent class.

mss19:08:21

thanks, I figured as much

mss19:08:30

something must be weird w the package I’m using v documentation

mss19:08:06

just wanted to make sure I wasn’t crazy and there wasn’t some special syntax for importing an interface