Fork me on GitHub
#clojurescript
<
2016-07-29
>
vinodg04:07:34

how to do json padding in clojurescript ? can any one help

danielcompton05:07:25

@vinodg: are you talking about JSONP?

danielcompton05:07:00

if so, you would probably provide the munged function name as the callback

danielcompton05:07:34

i.e. if the function was my.cool-ns/cool-function you would provide my.cool_ns.cool_function

danielcompton05:07:07

it’s a bit late here for me to figure out if the same method would work with advanced compilation, but I think it would

danielcompton05:07:33

ah, well it wouldn’t work just like I’ve described

danielcompton05:07:52

but you should be able to get the name of a function somehow and pass that through

rarous06:07:28

Hi, do you have any solution to measure code coverage of cljs code?

rarous08:07:18

@vijaykiran: yes, but for cljs.

vijaykiran08:07:38

oh, I’m not aware then

ezmiller08:07:36

Hi All, can anyone suggest how I’d get started working with D3 using clojurescript? I have a little data viz project I’d like to complete with these tools.

ezmiller09:07:12

but that has been deprecated in favor of this: https://github.com/lynaghk/c2

ezmiller09:07:18

which has also been deprecated!

borkdude09:07:07

@ezmiller: I haven't used D3 much, but why would it be different from other things like jquery plugins?

ezmiller09:07:08

@borkdude: Not sure I understand your question. D3 is a library like jQuery. My question is about interop libraries that might help me get up and running more quickly.

ezmiller09:07:36

Found this: http://www.szakmeister.net/blog/2015/nov/26/clojurescript-d3-and-reagent/ + the deprecation note on c2 suggests looking at using React through Rum.

hlolli10:07:56

If so unlikely someone remembers my question yesterday. Anyway moral of that story is, cljs.reader/numeric? does not work in any type of closure optimization (at least when used in sequence).

thheller10:07:25

@hlolli: not sure what you are referring to but I'm very certain that cljs.reader/numeric? works the same in every mode

hlolli10:07:43

yes it disfunctions the same in every mode. But works with figwheel, for reasons I cant understand. I used it as input validator, and I was getting messages: could not read QNAME in the js console.

thheller10:07:55

what do you expect it to do?

thheller10:07:21

and since it definitely never prints anything to the console, I suspect that you are looking at the wrong thing

thheller10:07:54

do you have some code that uses it you can share?

hlolli10:07:21

I promise to file issue on github early next week with reproduceable bug. But I was basically using three different ways to get value of the element, from there I validated the input (in a for loop (and the same was for map)). It works now exacly the same after I made my own regex number validation.

thheller10:07:19

goog.string.isNumeric = function(str) {
  return !/[^0-9]/.test(str);
};

thheller10:07:59

just curious how you are using it

thheller10:07:15

since that is basically all that cljs.reader/numeric? does

dimovich10:07:55

how to translate this to cljs?

dimovich10:07:58

element.g().attr('class', 'translate') .g().attr('class', 'rotate') .g().attr('class', 'scale') .append(childNodes);

thheller10:07:48

@dimovich:

(-> element
    (.g)
    (.attr "class" "translate")
    (.g)
    (.attr "class" "rotate")
    (.g)
    (.attr "class" "scale")
    (.append childNodes))

dominicm10:07:10

Is clojurescript supposed to destructure js objects in fn arguments? With [{:keys [foo]}] to do (-.foo)? It seems to have stopped working.

thheller10:07:20

@dominicm: no that never worked, :keys is for clojure maps only

dominicm10:07:40

Ah, maybe I am misreading code then. Just needed a bit of a sanity check

anmonteiro11:07:43

@mattly: thanks, I found that one a bit after I posted my question, seems it’s what I want. I’ve also created a CLJSJS package for other interested folks

anmonteiro16:07:18

copy from #C0E66E1H7: I’m having a problem by importing cljsjs.highlight.langs.clojure and cljsjs.codemirror.mode.clojure both are named clojure.inc.js so I end up really only having one of them (edited) ¯\(ツ)/¯ anyone knows how to solve this?

anmonteiro16:07:40

besides manually downloading one of them and feeding it to :foreign-libs under a different name, is there any other solution?

dnolen16:07:10

@anmonteiro: the names need to be different

anmonteiro16:07:01

@dnolen: right, I suppose this deserves an issue in CLJSJS then, to avoid conflicts between packages

dnolen16:07:38

@anmonteiro: perhaps a better an alternative would be place those files in a location that matches their namespace but it’s not clear to me at the moment how much work that would entail

dnolen16:07:04

would probably take a patch for that behavior

anmonteiro16:07:23

@dnolen: that makes sense, I’ll open an issue in JIRA then

fenton20:07:43

can one set environment variables (config) with cljsbuild? otherwise how do people handle environment variables in clojurscript with lein?

darwin20:07:16

just be aware that this does not work safely when you spawn multiple lein tasks in parallel: https://github.com/weavejester/environ/pull/53

fenton20:07:38

@darwin does this work in a clojurescript environment with cljsbuild?

darwin20:07:40

well, "clojurescript envrionment” is in fact “clojure environment” under lein-cljsbuild

darwin20:07:35

what do you want to do? do you want to override env variables for particular cljsbuild? or use env vars in your cljs code?

fenton20:07:49

but will this key off: lein cljsbuild once dev and lein cljsbuild once min ?

fenton20:07:25

i want to set the azerk cljs console debug level to warn on production build but debug on development builds

fenton20:07:10

right now I'm just setting export CLJS_LOG_LEVEL=DEBUG in my .zshev file

fenton20:07:32

which is okay, but I like having this info somehow contained in my project versus the shell user environment.

darwin20:07:55

ok, then I guess you want to use "lein profiles” feature for that, this is not really lein-cljsbuild related problem I think

darwin20:07:48

you want to use lein-environ and set :cljs-log-level “debug” under :dev lein profile and “warn” otherwise

fenton20:07:55

ok, so wasn't clear about that. cljsbuild id's correspond to lein profiles?

darwin20:07:16

no, cljsbuild ids are orthogonal to lein profiles

darwin20:07:53

lein profiles probably existed before clojurescript and lein-cljsbuild was born 🙂

fenton20:07:58

the two commands i issue are: lein cljsbuild once dev and lein cljsbuild once min for dev and production builds.

fenton20:07:20

do i have to add a with profile or something like that to my command to activate a profile?

darwin20:07:43

yes, unless some lein magic (tm) kicks in

darwin20:07:59

for example lein repl is magical and merges in :repl profile automatically

darwin21:07:07

and there are other magical cases

darwin21:07:17

I don’t hold them in my head, please refer to lein docs

fenton21:07:29

hmmm... for now i think i prefer the tradeoff of just using the shell user environment...

darwin21:07:33

a friendly note: lein-pprint is super handy tools when debugging profiles merging https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md#debugging

darwin21:07:49

there is one other trick you could do without diving deep into profiles

fenton21:07:10

i do cider-jack-in and dont want to figureout how to do a with-profile for that...maybe...

darwin21:07:32

you could use lein-shell to "shell out” into a bash script, alter your env there and return back invoking the same lein command

fenton21:07:27

my main concern is I'm old and I forget things very easily, so the least complicated usually wins for me...

darwin21:07:44

I wasn’t even born when those lein features were implemented, cannot really reason why they work the way they do 😉 Just learned how to achieve my goals with various workarounds

darwin21:07:42

[rant] I would like to switch to boot, but figwheel is not there, that is probably the only thing preventing me to do that

fenton21:07:44

but thanks for trying to hold this geezers hand to cross the road! lol

fenton21:07:21

I hear you. my local colleague is all into boot... he has the same comment.... he thinks about lein only because of figwheel! lol

fenton21:07:47

ok thanks again, let you get back to work! 🙂

darwin21:07:26

look at this 400+ lines project.clj of mine 😉 here it the shell-out lein task name aliasing trick: https://github.com/binaryage/dirac/blob/master/project.clj#L380

darwin21:07:10

@fenton: have you considered using lein aliases feature? you won’t be running it via lein cljsbuild once dev but instead lein my-alias-name, with lein-shell you should be able to even set env variable inline and then invoke lein again with original args

darwin21:07:40

or alternatively use “with-profile” and run original args with activated profile

darwin21:07:04

for example of the second approach, see this line: https://github.com/binaryage/dirac/blob/master/project.clj#L440-L441 basically I created bunch of “reusable” lein profiles and mix/merge them depending on invoked lein alias

darwin21:07:00

and sometimes from alias I “shell out” into a bash script to do some shell work if really needed (which might invoke other lein commands in turn) - (but this approach is probably spawning multiple lein JVMs)

fenton21:07:28

hmmm...i haven't considered that, but i perennially avoid becoming too dev-opsy. The amount of time my colleague devotes to boot...argh...reminds me too much of yak shaving. For my workflow, i just need those things to only disappear on the production server which i can do with the .zshenv file.

fenton21:07:38

@darwin: i'm a huge advocate of simple. I run cloc src perennially to see how many features i can achieve per lines of code.

darwin21:07:18

fair enough

dnolen22:07:50

oops totally missed it because I was at Curry On, ClojureScript is 5 years old people!