Fork me on GitHub
#clojurescript
<
2016-06-23
>
thomasdeutsch07:06:27

i have a question about js->clj and namespaced keywords: I try to use clojure.spec in my clojurescript app where i namespace all keywords that are map keys. {:url ""} is now {::url ""}. Most of my data i use in my app will be received as js-object, so i need to js->clj a lot. Now i need to namespace all those map keys. Is the only solution to write my own js->clj or do i miss something here? - maybe it is stupid to namespace all my map-keys? (js->clj jsobj :keywordize-keys true) is not namespaceing the keys.

thomasdeutsch08:06:36

i changed the js->clj to use a second param :ns. And i used a faster implementation by Darrick Wiebe. https://gist.github.com/ThomasDeutsch/667dc44cb301e646de76d92f54f921d1.

plexus09:06:45

just released a new version of Chestnut with the latest ClojureScript and Figwheel

rnandan27312:06:27

Has anybody used cljsjs/react-bootstrap "0.29.5-0" i.e react bootstrap components in reagent?

lewix12:06:48

@rnandan273: I used react-bootstrap before

tomjkidd13:06:19

does anyone know how to access/dereference an atom from javascript?

dnolen13:06:26

@tomjkidd: do you mean dereference a ClojureScript atom from JS?

dnolen13:06:47

what is the context? Like from a deployed production ClojureScript web app or Node.js?

tomjkidd13:06:25

Yeah, that is what I'm talking about, I created a simple map in cljs and used an ^:export to create a function that lets me pull it in in js using the namespace from cljs

dnolen13:06:03

@tomjkidd: so you will need to export cljs.core.deref and anything else you might need

tomjkidd13:06:09

And its with a browser, debugging with chrome, I can see the object, its just hidden in obj.state.arr and I don't know how to access it with it's keys

tomjkidd13:06:26

then call them as plain js functions from js

dnolen13:06:59

@tomjkidd: goog.exportSymbol is what you want to use since you cannot go and add ^:export to things already defined

tomjkidd13:06:26

Ok, that makes sense. Thanks again

dnolen13:06:46

@tomjkidd: maps implements ES6 Map interface

dnolen13:06:07

but you do need to be able to construct keywords to get at things of course.

tomjkidd13:06:31

right, I can find a way, worst case I will use strings

tomjkidd13:06:05

This is a prototyping effort working with web audio

myguidingstar16:06:36

Garden CSS question: what is the syntax to generate this translate3d(0,0,0)?

sbmitchell16:06:47

can't you just :transform "translate3d(0,0,0)" i.e put it in a string

sbmitchell16:06:01

seems to work fine for me

myguidingstar16:06:36

sure but I gave a simplified version

myguidingstar16:06:14

actually I want to use some vars and doing str is tiresome

myguidingstar16:06:19

defcssfn is what I need

noprompt16:06:40

@myguidingstar: yep that's the one.

myguidingstar16:06:24

thanks for the fun you bring to CSS 🙂

noprompt16:06:30

@myguidingstar: it makes me happy to know people are still finding utility in the library. 🙂 i can't apologize enough for not doing a better job maintaining it. 😕

sbmitchell16:06:44

@noprompt: I find the library fantastic. Been using it for almost a year now 🙂

sbmitchell16:06:00

@noprompt: while you are here...what is the best way to add "!important" flags when using color objects?

noprompt16:06:59

@sbmitchell: well you wouldn't add it to the color. it'd be in the declaration e.g. [<color> :important]

noprompt16:06:24

{:color [:blue :!important]}

sbmitchell16:06:52

can :blue be replaced with rgb definitions?

noprompt16:06:09

yeah. 🙂

sbmitchell16:06:14

ok I have been doing that wrong this whole time

sbmitchell16:06:46

I was doing some nasty stuff around that...`{:color (str (as-hex v/light-gray) " !important")}` where v/light-gray is a rgb definition in a variables ns

noprompt16:06:18

my recommendation is to use the vector notation for declaration values all the time. in fact, i wish i would have made that the design from the start.

noprompt16:06:42

it's much easier to write functions, update declarations, etc. with the vector notation. imho.

rauh18:06:17

@noprompt: Shouldn't it be {:color [[:blue :!important]]}?

noprompt19:06:23

@rauh: ha! yes! (i haven't worked on or with it in a long time!)

brian_mingus20:06:22

what's a good way to figure out which project i'm in?

dnolen20:06:06

@brian_mingus: can you clarify the question? what is this in relation to?

brian_mingus20:06:02

i have a shared library and i'd like to make some code conditional depending on who is using it

brian_mingus20:06:18

the code is in namespace foo. if i could access the namespace that required the code, that would be one method

brian_mingus20:06:47

another is to check for the general existence of a library in globals

dnolen21:06:57

@brian_mingus: ah you’re talking about detecting namespaces not projects it seems? it’s still not clear to me

cfleming23:06:19

Is it possible to use the CLJS compiler to analyse a namespace without fully compiling it? Specifically, I’m interested in introspecting information about vars in a namespace.

dnolen23:06:13

@cfleming: yes, cljs.analyzer.api/analyze-file

cfleming23:06:56

@dnolen: Awesome, thanks. Should that pretty much just require the classpath to be set correctly?

dnolen23:06:04

that’s right

cfleming23:06:13

That’s perfect, thanks.

dnolen23:06:15

@cfleming: we don’t store a ton of information beyond what Clojure does would be interested to hear if something is missing for tooling that we could put behind a flag

cfleming23:06:51

Ok, thanks - I’ll let you know. This is for generating stubs that can be indexed for libs that generate a lot of vars dynamically.

cfleming23:06:13

So I pretty much just need name, docstring and arglists to generate an empty function.

dnolen23:06:29

ok that’s all there