Fork me on GitHub
#clojurescript
<
2016-01-23
>
bhauman00:01:08

anyone know how I can have those !@#$-init.clj files caused by lein fast trampoline placed in a temp folder?

sonelliot02:01:07

does anyone have advice or references on synchronizing a mutable object hierarchy with an immutable one?

sventechie03:01:42

Anybody know how I can use JWT authentication from ClojureScript/Reagent? I can’t find any examples and I want to consume a RESTful API.

sventechie03:01:00

@sonelliot: there are a couple of data structure comparison libs — is that the kind of thing you’re looking for? Perhaps more specifics would help...

sonelliot03:01:38

I'm trying to create an immutable wrapper for Three.JS

sonelliot03:01:55

well, playing with the idea anyway

sventechie03:01:34

Re: my own question, looks like cljs-ajax supports :with-credentials for doing CORS and some auth, but it seems odd I find no search results of anyone using it thusly.

glenjamin08:01:21

Does anyone know if there's a write-up of how protocols are implemented under the hood in CLJS?

jrychter11:01:54

This is strange. I'm trying to script figwheel and it seems like only one source-path works. E.g. I have :source-paths ["src/cljs" "env/dev/cljs"] and ClojureScript compiler complains that my core app namespace is missing (only dev env code gets compiled). If I remove "env/dev/cljs", then my app does get compiled, but the dev env is missing.

jrychter12:01:32

Well, it turned out that judicious cleaning of all generated JavaScript files solved that particular problem…

sooheon13:01:01

Hi guys, I’m trying to convert this widget (http://codepen.io/thisoldbear/pen/YXoVgQ?editors=0010) to reagent/clojurescript, and I have a question about the getData fn at line 57. The cljs equivalent of the ajax call is something like

(GET ""
        {:params {:q location :APPID api-key}
         :handler handler
         :error-handler error-handler})
, but the example returns the response as a var directly, and the cljs-ajax example shows how to print this to the console. How can I write the handler to get this as a cljs map to directly touch the data?

dnolen14:01:53

@glenjamin: there isn’t, but it’s not that complicated

dnolen14:01:06

every protocol method produces a corresponding fn - this fn takes the first argument checks that it implements the protocol and invokes the instance’s implementation if it does

dnolen14:01:52

so protocols actually introduce a bit of indirection

glenjamin15:01:43

@dnolen: thanks, the bit I was interested in specifically is what that check looks up against: where do protocols live at runtime, and how are they identified

glenjamin15:01:05

Is there some type of mapping somewhere? is lookup O(n) on the number of implementations? If not, how are implementations attached to complex types?

glenjamin15:01:05

just a general pointer in the direction of the code would be awesome, I don't expect you to have to answer all that in detail :)

dnolen16:01:33

@glenjamin: like I said protocols fns just invoke the instance’s implementation

dnolen16:01:48

which is a plain old JS method on a JS type

dnolen16:01:23

deftype and defrecord really just produce JavaScript types

dnolen16:01:53

by doing it this way we can lean on JS VM inlining etc.

dnolen16:01:17

if you’re interested in how it works I would examine the defprotocol deftype defrecord macros. they are doozies though - there’s a lot of fiddly performance related stuff in that code.

xcthulhu18:01:51

Hi! I'm trying to convert a nested hash-map (representing a tree) to hiccup. Should I use clojure.zip or should I just write a top-down recursive transformation?

xcthulhu18:01:03

I my trees, in practice, will never have depth greater than 3, so I doubt top-down recursive walk will blow the stack.

seantempesta18:01:03

Dumb question: how do you extract the value of a variable in a quoted expression?

cljs.user=> (def x "foo")
#'cljs.user/x
cljs.user=> '[x]
[x]

grav19:01:15

hey! happy cursive user here, but it’s running quite slow on my aged macbook air. What do you people use for ClojureScript development that has some of the same integration? (paredit, refac, completion in editor/figwheel repl etc)?

grav19:01:38

I’m thinking of trying out cider, but I’d really like something that didn’t require much setting up

grav19:01:38

@seantempesta: in clojure, you could do (eval ‘x)

grav19:01:17

seems bootstrapped cljs has eval, but I guess cljsbuild doesn’t?

mfikes19:01:52

Yeah, that’s what I’d say as well. simple_smile

mfikes19:01:23

You’d essentially need to evaluate the symbol, which means resolving it, etc.

seantempesta19:01:31

So if cljs doesn’t have eval (unless it’s bootstrapped), then how am I supposed to pass a value to an om-next transact! statement?

(om/transact! this '[(zip-change {:zip-text x}) :zip])

dnolen19:01:56

@seantempesta: you don’t need eval for that

dnolen19:01:01

just unquote

dnolen19:01:15

`[(foo ~1)]

seantempesta19:01:02

I tried that, but I’m getting (clojure.core/unquote x) as the value received by the mutate function

mfikes19:01:13

Did you use the backtick (syntax quote) at the beginning?

mfikes19:01:58

cljs.user=> (def x "foo")
#'cljs.user/x
cljs.user=> `[~x]
["foo”]

seantempesta19:01:22

Yep, that was it!

Mikko Koski19:01:57

I'm a bit stuck. I'm trying to get the Remove Sync Tutorial working, but I'm getting errors. Apparently I need the latest om version, 1.0.0-alpha29-SNAPSHOT, but that version is not in clojars. What's the easiest way to get the latest version? Do I need to git clone om repo and build it locally or am I missing something?

taylor.sando19:01:33

Clone it, then run lein install

dnolen19:01:38

@rap1ds: there’s is an Om channel

dnolen19:01:40

#C06DT2YSY

Mikko Koski19:01:40

@taylor.sando: Alright, I'll try that. @dnolen Oh, sorry, my bad!

Mikko Koski19:01:18

@taylor.sando: Oh, that was easy! I got the latest version installed, thanks!