This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-31
Channels
- # admin-announcements (1)
- # beginners (16)
- # boot (25)
- # braid-chat (7)
- # cider (4)
- # cljsfiddle (6)
- # cljsrn (1)
- # clojure (256)
- # clojure-austin (4)
- # clojure-ireland (1)
- # clojure-poland (15)
- # clojure-russia (80)
- # clojure-uk (2)
- # clojurescript (30)
- # core-async (14)
- # core-typed (3)
- # cursive (35)
- # datomic (1)
- # editors (28)
- # hoplon (32)
- # immutant (1)
- # jobs (8)
- # jobs-discuss (1)
- # juxt (6)
- # leiningen (8)
- # liberator (7)
- # off-topic (16)
- # om (69)
- # onyx (38)
- # re-frame (10)
- # spacemacs (1)
- # untangled (117)
http://stackoverflow.com/questions/36300173/compiling-snippets-of-clojurescript-into-javascript
(ns one.query-test
(:require [cljs.analyzer.api :as analyze]
[cljs.compiler.api :as compiler]))
(def one (assoc-in (analyse/empty-env) [:ns :name] 'one))
(let [ast (analyze/analyze one '(defn plus [a b] (+ a b)))]
(compiler/emit ast))
=> "one.plus = (function one$plus(a,b){\nreturn (a + b);\n});\n"
(let [ast (analyze/analyze one '(fn [a b] (+ a b)))]
(compiler/emit ast))
=> "”
I’m a bit lost; how to go from a js array containing objects, to a clj vector with maps?
I want to map over each object changing some keys, but can’t seem to just map over the js array
Perhaps something like this? (mapv #(js->clj %) (js->clj jsArray))
@johannesgu: seems to work nice, still running in some other problems though
without optimizations the compiled js looks as it should
Ignore everything I said, externs were not in place... 😅
I'm working with a JS lib (`aws-sdk`) where every api takes a 2-arg (err, data) callback. Anyone have have good advice for unraveling this flow? I'm thinking something like this is the way to go: http://bryangilbert.com/code/2013/07/19/escaping-callback-hell-with-core-async/ but wondering if anyone has any other ideas
note that channels don't have error semantics, if you want an error-aware asynchronous abstraction i'd recommend promises
or you can use https://github.com/funcool/promesa for nice syntactic abstractions and a richer API
@jiyinyiyong: not sure but i don't know anybody who uses it, neither in Clojure nor ClojureScript
@bbss: streams also have first-class error semantics but are overkill for just one result in my opinion
@jiyinyiyong: i'd ask in #C051QCQUF, hopefully someone can give you better info on ClojureScript support
note that you can use Google Closure Compiler's type annotations, see https://github.com/clojure/clojurescript/wiki/Compile-Time-Type-Checking
@pbostrom: ad additional error channel, another possible technique to signal errors is to install global error handler and then just simply throw errors from within your go blocks. this is not as clean as rigorously supporting error channels, but can be more practical if you have full control over top application context
Channels can contain any error semantic (and mapped over to obtain a Monad like behavior), I would just pass back a map with :result
and :error
if I understood the problem correctly
I found a weird easter egg with cljsfiddle you might enjoy: http://cljsfiddle.com/#gist=f3dc62fc941aee78dba5020dc5dcbdcb