This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-03
Channels
- # admin-announcements (2)
- # arachne (1)
- # architecture (6)
- # boot (316)
- # cider (7)
- # cljsrn (7)
- # clojure (169)
- # clojure-argentina (3)
- # clojure-belgium (1)
- # clojure-canada (4)
- # clojure-india (1)
- # clojure-russia (39)
- # clojure-spec (27)
- # clojure-uk (55)
- # clojurescript (213)
- # css (1)
- # cursive (20)
- # datavis (2)
- # datomic (52)
- # devcards (3)
- # dirac (78)
- # emacs (20)
- # events (1)
- # funcool (3)
- # hoplon (15)
- # jobs-rus (2)
- # om (57)
- # onyx (82)
- # overtone (1)
- # re-frame (10)
- # reagent (1)
- # ring-swagger (46)
- # spacemacs (7)
- # specter (31)
- # spirituality-ethics (1)
- # sql (43)
- # test-check (1)
- # testing (4)
- # untangled (30)
can someone help me to fix the syntax here: I’m confused of what should be used refer-macros
or require-macros
:
(:require [cljs.core.async :refer-macros [go] :refer [<! !>]])
this seems worked:
(ns foo
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :as async :refer [put! chan <! >! close!]]))
But I thought require-macros
is “old way”, no?@ag you can’t :refer-macros
from cljs.core.async
because they are in different namespace cljs.core.async.macros
https://github.com/boot-clj/boot-cljs-devtools this may help, not sure though
@anmonteiro: @darwin: Right, my problem from yesterday is not in the expression generated for ClojureScript but that I'm calling the same generation code from Clojure and from ClojureScript - but with a few differences and those differences mean what I get back when calling it from ClojureScript is backtick-quoted once or twice too often, so instead of a list I get back an unevaluated expression made of clojure.core/seq
, clojure.core/concat
, clojure.core/list
etc.
@jannis: unless you’re using bootstrap Clojurescript, reader conditionals won’t work
you’ll want to use something like this: https://groups.google.com/forum/#!topic/clojurescript/iBY5HaQda4A
JS question: If I have a chain of promises like (-> (js/fetch url #js {:method "POST"}) (.then #(.json %)) (.then #(handle %)) (.catch #(prn "Opps" %)))
-- if handle
raises an Error, this will be caught by the .catch
handler. What if I don't want to catch those exceptions there?
I.e. I'd like an actual exception to be raised, not just an errback to be called
the promise handlers are async so you can't reraise the exception like synchronous exception
but my handle
function may do nay kinds of operations that have nothing to do with this promise
so I don't want those exceptions if they occur to be caught by the fetch .catch
method
hah, according to http://stackoverflow.com/a/30741722/239678 the way to throw
inside a .catch
block is to use setTimeout
. The JS world really is weird and wonderful
@pesterhazy: you might not want to add such a dependency in your project for X reasons, but that’s the type of problems core.async
solves really well
yeah, core.async wouldn't help in my case (it's about interop with a JS library)
@anmonteiro: I'm calling a function in a .cljc
file from the macro and from ClojureScript, so there I can detect whether or not I'm "in the macro" or not. It's already working 🙂
core.async does not solves very well something that promise and rx streams (imho much better)...
it lacks of error handling and you should build your own, if you join that together to the idea of if every one uses core.async every library will use its own approach for handle errors...
it's not an option for me
core.async is very nice piece of software but it is not a silver bullet and I think it does not fits very well as promise abstraction
I am confused and I don’t know how to explain to someone when should we use require-macros
and when require
with refer-macros
.
@ag it is confusing 🙂 the rule is: refer gets cljs, refer-macros gets clj ... but it becomes cloudy when you introduce cljc 🙂
Initially I thought they both are basically the same - just the first form is deprecated. Apparently Clojurescript compiler thinks differently
they are different yes.
Macros can only be defined in Clojure (clj) and applied at compile time
(this is not strictly true because the bootstrap compiler exists now, but that's the easiest way to think about it)
There are other forms that work, such as putting clj macros and cljs code in a cljc and requiring with refer-macros
but I encourage you to avoid the syntactic sugar, because it is hard to keep track of in your head.
ie: always use require-macros imo
never use require refer-macros
(just my opinion)
more specifically to your question of why :require ... :refer-macros ... doesn't work... because that namespace cannot be required (there is no clojurescript file for that ns)
hi all, I was working on a proof-of-concept to implement a swagger-based API with a node/clojurescript backend. I keep running into an issue that perhaps one of you will understand
the issue, as far as I can tell, is that lots of the swagger libraries end up using other NPM libraries like uri-js
but this library has conditionals that act differently for compiled vs not compiled javascript, that I dont fully grasp
what I do understand is that when I run this in my cljsbuild, it is trying to compile those libraries and bad things happen
so, what I am wondering is: is this behavior of compiling node_modules configurable in the cljsbuild
i was wondering if there is something like a cljsbuild flag, or perhaps an option in the nodejs/require form that allows it to be treated differently
@ghaskins im not sure what you mean by compiling these other libs. You can require node modules with js/require at runtime just as you would the built in libs
I'm trying to use :foreign-libs; the example showed the use of a url (http://...) to load the file, but my cljsbuild is giving a "no such file" error and simply appending the url to the classpath. What am I supposed to be doing?
but the problem is, all of those libraries basically shut themselves off if they are being compiled
i am unfamiliar with the details of packing up foreign libs, i know there was alot of work on that done recently, someone else will have to help
@pat: as far as I know, that is what i am doing….i have lein-npm reference the deps, they get pulled down into node_modules, and then I (nodejs/require) them in my cljs code
sorry, missed a step, lein-npm def in project.clj, "lein npm install” pulls them into node_modules, and then (nodejs/require) at run time blows up
you mean do not reference them in lein-npm/project.clj and just npm-install manually?
it seems the act of invoking the (nodejs/require) form is what triggers the Module._compile
@ghaskins : clean your project, ignore 'lein npm'. just use npm manually to install package and then require globally through js/require
well, I just downloaded it locally, and it's not giving errors when I give it the right path, so I assume that part is working
you require the same thing you put in provides, but its a pseudo-namespace, have to use js/somelib to access it
for example: look at all the react wrappers out there. React is bundled in by you still have to use js/React.... to use it
either when I run (require 'JSEncrypt) in the repl, or try to build a file with :require [JSEncrypt :as jse]
my guess its either an incompatiblity for this particular library with clojurescript, or I need to pass an option to the js/require
you can't alias it either. (ns foo.core (:require [some-js-lib])) (def a (.-a js/somelib))
well, adding the alias back in didn't break it again, so something else must have changed
@ghaskins can you start just a simple node javascript repl and require it? theres no reason why cljs should be incompatible
pardon me, I am not a node/js expert…what is the syntax to require from a pure node repl?
yes, “require(‘uri-js’)” works in node repl, (js/require “uri-js”) blows up in figwheel with the same stack trade
I am reasonably confident its because of that Module.compile() being invoked, but I dont know enough about what the js/require form really does
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.cljs#L224
@shader hot-reloading code has its own state to consider. start clean without the alias, should be fine
@ghasking js/require is identical to using reuire from node. does it work without figwheel? ($ lein cljsbuild once)
I see the same behavior regardless of whether I do the js/require in figwheel repl or on cljsbuild output
@ghaskins to be clear, you tried a build without figwheel, just a $lein cljsbuild once, ran the file, same problem?
so I have a clojure webserver that serves clojurescript, how can I pass environment variables into the clojurescript code?
same way you pass all other data 🙂
depends on your app, but that's one good approach
any other patterns.. I could serve the HTML file and inject javascript in script tags taht contains the ENV vars
and really no different than the ajax call. browser still has to request a different resource
Hey all. I have a protocol defined in one namespace and a record that implements that protocol stored in my app’s state. In a different namespace I pull that record out of the state. Now how do I execute a function on it?
@jr Thank you so much! I didn’t realize the function was defined in the ns versus in the protocol itself
@ghaskins i changed it to :optimizations :simple and it worked. so it looks as though whatever build system the lib author is using is interacting with our closure code somehow, node dependencies aren't resolving correctly
I mostly work on JVM clj but was forced to learn node/cljs because of an environmental factor
yeah, right now I have the cljs talking GRPCs fine…but problem is I cant currently surface HTTP2 through the load balancer
so, i was wondering if I could swap out the GRPC interface for swagger over HTTP/1.1 but I might have to tier it
well, what I wanted to do was surface the GRPC natively, but the version of HAProxy that is baked into OpenShift seems to puke on the binary HTTP2 payload
so, as an alternative, I was wondering if I could swap out the GRPC endpoint for something HTTP/1 based, like a basic swagger REST endpoint
I was trying to use (.use app …) but my app was a standard (def app (js/require ..))