This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # 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)
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 😞
I don't understand How I can use
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
@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
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.
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.
@settinghead: from my experience there is no (easy) way to do in in
boot provides a
sift task for moving around files (and it is actually what
cljsjs uses for generating packages)
You can evaluate
(ns foo.macros) (defmacro resolve-it [ns sym] (str (ns-resolve ns sym)))
(foo.macros/resolve-it clojure.core inc)which will expand to
ns-resolveworks, but it is executing in Clojure. If you try to remove the wrapping
strcall, then you are going to get an error
No method in multimethod 'emit-constant' for dispatch value: class clojure.lang.Var
ns-resolveis running in Clojure, there is no way it can resolve symbols in your ClojureScript code.
@virmundi: by default,
(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)
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)