Fork me on GitHub
#beginners
<
2015-09-16
>
az02:09:34

Hi, any guidance on setting up a rest api using datomic? I see ring and some other libs, any pointers on where I should start?

Petrus Theron10:09:44

Is it possible to easily use NPM libs from Cljs? E.g. I want to use this Firebase Queue Worker thing, but without writing JS: https://github.com/firebase/firebase-queue

sergeylaptev11:09:42

Hi, how I can escape double quotes sign (") in clojure string?

sergeylaptev11:09:47

str.replace(/\"/g, '\\"') analogue in JS

sergeylaptev12:09:15

(defn escape-double-quotes [str]
  (s/replace str #"\"" "\\\\\""))

dnolen12:09:19

@petrus it’s not straightforward, there’s some ongoing work that will make it simpler for build tools to consume NPM, but it’s not going to be an officially supported thing.

dnolen12:09:05

in the case of Firebase you shouldn’t need NPM anyhow, http://cljsjs.github.io

dnolen12:09:18

@curtosis it’s not desirable to write a function for those cases, you want Google Closure to optimize that stuff. If you’re actually dealing with JSON data then there’s goog.object which has all the helper fns one would need.

roberto14:09:27

how do you specify that something should be a map with prismatic schema?

surreal.analysis14:09:27

Not 100% sure, but I think you could do something like:

(def GenericMap {})

jhchabran14:09:05

Hi everyone, I’ve came across this code from https://github.com/suprematic/khroma README

(runtime/send-message msg {:extensionId “some..”})
which is implemented with (https://github.com/suprematic/khroma/blob/master/src/khroma/runtime.cljs#L91)
(defn send-message [message & options]
  (let [{:keys [extensionId options responseCallback]} (apply hash-map options)]
    …
So the implementation says the proper usage is in fact`(send-message msg :extensionId “some”…)` which contradicts the readme. It feels weird to me to pass around options like this, especially since message will mostly be a hashmap, so it’d be better written like in the readme. Which one do you think is the most meaningful/idiomatic ? (send-message msg {:foo “bar"}) or (send-message msg :foo “bar”) ?

surreal.analysis14:09:07

Do you know the keys in the map?

curtosis18:09:42

@dnolen: thanks! I figured there had to be a good reason ... too many of us Lispers around to leave something like that un-abstracted repeatedly. 😉

paulb20:09:18

trying to understand how transit works - if msg is the string representation of a ClojureScript map (sent from client to server using transit-cljs and a websocket) what is the simplest way to parse msg back into a Clojure map on the server side?

dnolen20:09:22

@paulb not sure I understand the question. If you use transit-clj and transit-cljs there isn’t anything to do, it just works

paulb21:09:12

I got it working by doing (t/read (t/reader (ByteArrayInputStream. (.getBytes msg)) :json))

paulb23:09:20

I find it confusing with transit-clj write is an impure function that returns nil whereas with transit-cljs write is a pure function that returns the result you need (same with read)