Fork me on GitHub
#clojurescript
<
2016-02-24
>
richiardiandrea03:02:17

so if I have a clojurescript library and I want to include cljs source only, can I just use lein deploy clojars ?

mfikes03:02:43

@richiardiandrea: You’ll also end up with some other META-INF directory structure in the jar

kingoftheknoll05:02:21

Ah… fixtures that seems like a valid path

cddr06:02:35

Has anyone written an http client api that works the same way on both node and the browser?

imjonathan06:02:42

(defresource route :available-media-types ["application/json"] :allowed-methods [:post] :authorized? #(contains? #{:user :admin} (-> % :request :basic-authentication :role)) :known-content-type? #(check-content-type % ["application/json"]) :malformed? #(parse-json % ::data) :post! #(let [id (str (java.util.UUID/randomUUID)) problem (::data %) cust (-> % :request :basic-authentication :cust) ] (j/insert! db-conn :job (assoc {} :idjob id :problem problem :submitted (timec/to-timestamp (java.util.Date.)) :idcustomer cust :status "pending")) (log/info "posting to " @jobq) (sqs/send sqs-client @jobq id) {::id id})

benjyz10:02:34

what components would make sense to build a dashboard in Cljs?

benjyz10:02:32

react grid layout..

bensu13:02:27

@kingoftheknoll: there is a #C08LK2DH7 channel as well.

bensu13:02:05

the error seems related to a type error (undefined is not a function), and not so much to the async nature of the code.

kingoftheknoll13:02:52

@bensu looks like that channel is empty.

mhuebert17:02:00

For anyone using Bootstrapped CLJS with :dump-core false, then loading the analysis cache later - I was previously using the analysis cache produced by lein cljsbuild (per https://github.com/clojure/clojurescript/wiki/Optional-Self-hosting), but this cache is missing macro data. This morning I tried printing the output of (cljs.js/dump-core) to console (encoded with transit) - this cache contains the missing macro data & has also resolved some other macro resolution problems I was having. Below is a gist of how I did it (I copy/pasted the result into a file) but this will be even easier when the next CLJS release is cut and we can (require [cljs.js]) from Planck. https://gist.github.com/mhuebert/c9fffa98812e6627c2a8

mfikes17:02:11

@mhuebert: I can’t recall the details surrounding this, but FWIW Planck definitely handles cljs.core macros cache as a separate thing, grabbing it from out/cljs/core$macros.cljc.cache.edn.

shaun-mahood17:02:56

@mfikes: Somewhat off topic from the current conversation, but have you looked at into the possibility of running Planck (or what would be required to have something similar) on Windows?

mfikes17:02:35

@shaun-mahood: Yes. High level thoughts are to either convert the Objective-C portion to a more portable language like C, or perhaps even using http://www.cocotron.org

mfikes17:02:20

@shaun-mahood: Actually, Planck has become somewhat stable now that most of the main bits work, so it makes it more palatable to consider doing such things. If anyone want’s to take a look at Cocotron, it might be trivial, or it might be a pain in the you-know-what.

mfikes17:02:52

Another thought is for someone to build something atop Node, and get the portability for free.

shaun-mahood17:02:01

@mfikes: Cool! I figure you'll get bored now that you've run out of bugs in bootstrapped and will probably get to it before anyone else simple_smile

mhuebert17:02:49

@mfikes: I see. sometimes when I looked for core$macros cache, I couldn’t find it, but I see it now, so I’m a bit confused. maybe due to different compiler options i’ve been using

kul17:02:48

I am interested in knowing if cljs is being used for server side development (nodejs)?

shaun-mahood17:02:35

@kul: There are definitely people using it with nodejs for server side development in production.

kul18:02:50

Is there any example i can look at

kul18:02:34

How to install npm deps, using them etc

kul18:02:52

Packaging and deployment

7h3kk1d19:02:25

Trying to get started building a dashboard type thing in clojurescript should I jump straight into om/om-next or take a more elementary approach. I’m already familiar with the clojure(script) syntax

venantius19:02:50

I think Om is really approachable

venantius19:02:02

I haven’t tried om next yet

7h3kk1d19:02:11

Cool. Thanks

7h3kk1d19:02:22

I looked at the tutorial and it seemed fine.

7h3kk1d19:02:44

But thought I should start with clojurescript and played around with just figwheel but it seemed daunting to build anything with that little.

straistra19:02:48

@7h3kk1d: I am only a beginner, but I found Om a bit unintuitive at first, and then I happened to glance at Reagent, and I've never looked back. I might look at Om Next at some point, but right now I am fine in Reagent.

7h3kk1d20:02:00

Cool, I’ll look at that

seriousbug20:02:09

@7h3kk1d: Same as straistra here, I started with Reagent then added re-frame on that. It might be a good choice if you want something more minimal maybe

danielcompton20:02:48

How do I add a custom comparator to a record I'm defining?

mfikes20:02:14

@danielcompton: IComparable

(defrecord Foo [x]
  IComparable
  (-compare [_ o] (compare x (.-x o))))
  
(sort [(Foo. :a) (Foo. :x) (Foo. :m)])  

; => (#cljs.user.Foo{:x :a} #cljs.user.Foo{:x :m} #cljs.user.Foo{:x :x})

danielcompton20:02:59

Awesome, wasn't sure if there was such a thing after reading https://github.com/clojure/clojurescript/wiki/Comparators

mfikes20:02:26

Ahh Fogus-era stuff simple_smile

mfikes20:02:12

@danielcompton: (I added a quick note to the top of that page, in case anyone else treads down that path.)

danielcompton20:02:59

@mfikes: how does IComparable handle comparing objects of different type?

mfikes20:02:46

@danielcompton: I was wondering the same. It probably doesn’t handle partial orders, etc. hrm.

danielcompton20:02:00

Fail (test-daymask-sorting) (Error:NaN:NaN)
	Expected (= (sort [(daymask "1000000") "abc" (daymask "1000000")]) [(daymask "1000000") (daymask "1000000") "abc"])
	Actual: #object[Error Error: No protocol method WeekdayMask.sort-value defined for type string: abc]

mfikes20:02:51

@danielcompton: My guess: Throw: (throw (js/Error. (str "Cannot compare " x " to " y)))))) is in the impl of compare

danielcompton20:02:45

Fail (test-daymask-sorting) (Error:NaN:NaN)
	Expected (= (sort [(daymask "1000000") "abc" (daymask "1000000")]) [(daymask "1000000") (daymask "1000000") "abc"])
	Actual: #object[Error Error: Cannot compare abc to [object Object]]

danielcompton20:02:12

does look like it doesn't it simple_smile

mfikes20:02:05

@danielcompton: Just be careful, it may be comparing string to your object by chance and not the other way around

danielcompton20:02:36

yeah, in our case I think if we're ever comparing any other type with our custom record type then we should be throwing an exception anyway

mfikes20:02:17

@danielcompton: Yeah, it will just go into your defrecord IComparable impl, I think you’d need to test types and throw there.

mfikes20:02:45

@danielcompton: (This is my guess by looking at the source for compare.)

danielcompton20:02:36

all makes sense, thanks for your help simple_smile

iwankaramazow20:02:27

what's the best way to enable custom dev flags in cljs? example: (if (we-are-in-dev-mode) enable-super-secret-logging disable-secret-logging)

iwankaramazow20:02:51

any way to define the we-are-in-dev-mode ?

mfikes20:02:16

@iwankaramazow: I wonder if a dynamic var is what a lot of people use for that.

mfikes20:02:59

@iwankaramazow: I’ve done that. In my case (iOS app), the app itself knows that it is a DEBUG build or not, and then it sets the dynamic var on the ClojureScript side.

iwankaramazow20:02:02

Awesome, thanks!

iwankaramazow20:02:38

I'm just looking for a way to comment out requires in prod, because of dynamic module loading

iwankaramazow20:02:36

There isn't a way (yet) to combine figwheel/dynamic module loading at runtime during development

mfikes20:02:23

@iwankaramazow: If I understand you correctly, for that kind of thing, I’ve resorted to using two extra source paths, one for dev and one for prod. Each path contains the same namespace, where one side is stubbed to do nothing and the other pulls in deps. All code can refer to the “chameleon” namespace.

mfikes20:02:54

(The main bit is ”dev-src” vs. ”rel-src”.)

iwankaramazow20:02:28

@mfikes: oh wow, interesting! I'm using a more cavemen style approach with commenting-out stuff

mfikes20:02:25

For example, in that project ”dev-src” had a namespace that initialized Weasel, which I didn’t wan’t in prod. So, both sides had a namespace (say env.core, with an init fn), with the dev init setting up Weasel, and the prod init being empty.

7h3kk1d20:02:34

Thats nifty

mfikes21:02:37

@iwankaramazow: Yeah, the problem is trying to figure out how to dynamically comment out things in :require. I think ns forms are pretty static—just data, no logic. But I could be wrong.

mfikes21:02:16

I too used to be a caveman, employing #_ like an animal. simple_smile

iwankaramazow21:02:45

Thanks a lot for the response