This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-13
Channels
- # admin-announcements (1)
- # alternate-reality (2)
- # beginners (15)
- # boot (309)
- # cbus (1)
- # cider (4)
- # cljs-dev (4)
- # clojure (199)
- # clojure-madison (5)
- # clojure-russia (14)
- # clojurescript (59)
- # community-development (57)
- # core-async (5)
- # cursive (8)
- # datavis (6)
- # datomic (1)
- # dysphemism (11)
- # emacs (5)
- # euroclojure (1)
- # hoplon (3)
- # off-topic (103)
- # om (52)
- # onyx (3)
- # parinfer (1)
- # proton (15)
- # reagent (4)
@raspasov: that’s the behavior i’d expect
Why do you expect it to print two things?
@isaac_cambron: because I'm pretty sure those are the semantics of promise-chan
@isaac_cambron: also it behaves differently in Clojure vs ClojureScript
promise-chan function Usage: (promise-chan) (promise-chan xform) (promise-chan xform ex-handler) Creates a promise channel with an optional transducer, and an optional exception-handler. A promise channel can take exactly one value that consumers will receive. Once full, puts complete but val is dropped (no transfer). Consumers will block until either a value is placed in the channel or the channel is closed. See chan for the semantics of xform and ex-handler.
yeah, it’s possible that i’m the one misunderstanding promise channels, now that i look into it
I was trying to use it in React/Om to orchestrate some animations between components, basically have one promise-chan that gets passed to multiple components and they "wait" till one (and exactly one) value gets delivered to promise-chan by their parent
Yeah, now that I’ve revised my understanding of promise channels, I agree with you and am thus no help 😞
@isaac_cambron: no worries!
I don't understand How I can use resolve
or ns-resolve
in macros for cljs. Them does not works in the same way as in clojure 😞
For the same usage in clj it returns a proper var and in the cljs it returns always nil (independently if I'm using resolve
or ns-resolve
.
@niwinz: Well, in regular ClojureScript, the macro is executed in Clojure. If you are willing to opt into bootstrapped ClojureScript in order to gain this, then it can be done building atop cljs.js
. Here is an example in Planck, FWIW:
cljs.user=> (ns foo.core)
nil
foo.core=> (def a 3)
#'foo.core/a
foo.core=> (in-ns 'cljs.user)
nil
cljs.user=> (require '[planck.core :refer [ns-resolve]])
nil
cljs.user=> (let [sym (ns-resolve 'foo.core 'a)]
#_=> (prn sym)
#_=> (prn @sym))
#'foo.core/a
3
nil
@kauko: If you are willing to bring in cljs.js
, then you can build things that do that: https://gist.github.com/mfikes/7342d6321868d4fc4a3d
wait, what do you mean by cljs.js
? Isn't that the javacript libraries packaged for clojurescript -thingy?
No… (sorry, it is an overloaded set of 6 characters). I’m referring to the API namespace for accessing bootstrap ClojureScript capabilities.
@kauko: So, I’m essentially saying that if you are willing to bring on a decent amount of complexity and additional generated code size, give up on certain optimizations, it is possible.
I'll just have a function with the signature [thing thing]
instead of just [thing]
. No big deal.
It seems like doing a core.async
put!
in the middle of a CLJS file (not in function but right in the global scope) prevents the code that follows the put!
to be run. Has anybody had this problem?
Where should I report a bug in the tutorial at https://github.com/omcljs/om/wiki/Remote-Synchronization-Tutorial -- I've got a patch that fixes it.
@mfikes What does that mean, exactly? It uses the JVM Clojure for macros? >in regular ClojureScript, the macro is executed in Clojure.
hello. I've got a rather odd case. In chrome extensions there are two environments that a javascript should file may find itself. This is mostly around which chrome specific apis are available at a time.
The background execution has access to an object named webRequest. The content script lacks such an object.
My problem is that the monolithic js file gets loaded into both. This causes the content script to fail loading.
@echristopherson: cljs is (usually) AOT-compiled into js. This means that macros are expanded by cljsbuild
(which runs on the JVM).
@virmundi: have you tried something along these lines? https://gist.github.com/oakmac/012e1e5973c3e996cc29
no problem, also check that gist again. There is exists?
which might be more idiomatic for this use case.
is there a way to use .css
files from a CLJSJS package in a leiningen project?
can’t seem to find any documentation on that
@settinghead: from my experience there is no (easy) way to do in in lein
, but boot
provides a sift
task for moving around files (and it is actually what cljsjs
uses for generating packages)
@echristopherson: Yeah, what @potetm said. But, getting more to the point, consider
(ns foo.macros)
(defmacro resolve-it [ns sym]
(str (ns-resolve ns sym)))
You can evaluate (foo.macros/resolve-it clojure.core inc)
which will expand to "#'clojure.core/inc”
. So, ns-resolve
works, but it is executing in Clojure. If you try to remove the wrapping str
call, then you are going to get an error
No method in multimethod 'emit-constant' for dispatch value: class clojure.lang.Var
Which further reinforces the idea that the macro is expanding in Clojure to a JVM object, which is then passed to the ClojureScript compiler for JavaScript emission, which it can’t do.
The bigger problem is that, since ns-resolve
is running in Clojure, there is no way it can resolve symbols in your ClojureScript code.should (js->clj o) create a clj map for a javascript object? I tried that but still can't use (:url as-map)
@virmundi: by default, (js->clj x)
converts JavaScript Object keys to string, not keywords. You can pass (js->clj x :keywordize-keys true)
to recursively convert the string keys to CLJS keywords
or leave the keys as strings and use (get clj-x "url")
(although keywords are easier to read / use)
what does it do with ES6 symbols?
js->clj
and clj->js
are convenience helpers only useful for small amounts of data, if they can be avoided I would
@settinghead: You can serve the files from cljsjs using Ring or you could use a Lein plugin which can read files from classpath and compile Less or Sass files to CSS (my less4clj and sass4clj projects implement this)
@juhoteperi: thanks. i’ll take a look