This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-18
Channels
- # beginners (56)
- # boot (1)
- # cider (96)
- # cljs-dev (148)
- # clojure (60)
- # clojure-austin (11)
- # clojure-france (2)
- # clojure-italy (5)
- # clojure-russia (11)
- # clojure-spec (31)
- # clojure-uk (5)
- # clojurescript (52)
- # community-development (37)
- # cursive (3)
- # data-science (8)
- # datomic (14)
- # devcards (2)
- # emacs (1)
- # fulcro (13)
- # hoplon (1)
- # immutant (2)
- # luminus (3)
- # off-topic (2)
- # onyx (16)
- # parinfer (38)
- # re-frame (8)
- # reagent (5)
- # shadow-cljs (332)
- # spacemacs (5)
- # specter (5)
- # sql (6)
- # vim (52)
Hey guys. I'm having a problem with my clojurescript cljsbuild setup. I'm trying to have a <button>
's onclick attribute set to a Clojurescript function in my core.cljs file defined with an ^:export
meta tag. I included the outputted file from my js
folder in resources/public
which is clojurescript.js
. I set the onclick attribute of the button to cljs.core.greet()
, but when I click the button, I get that cljs is not defined
. What's going on here ?
@jmb do you have a function greet in a file cljs/core, given that you have source-path "src" (maybe among other source-paths) then it would be "ROOT/src/cljs/core.cljs" in which file you have
(ns cljs.core)
(defn :^export greet [] (println "Hello World"))
if so, does it work with other optimizations than :advanced?@hlolli Yes I have that exact same function except it has (js/alert "It worked")
inside. I'm experimenting right now in another branch if it works with other optimizations like :none
it shouldn't matter, Im right now running exported function in an advanced compiled browser code. Actually on shadow-cljs, it has some extern stuff prepacked so it may differ.
I suppose. I just wanted to simply setup Clojurescript so I can provide basic functionality to the site without having to write Javascript
hi, i’ve been trying to get code completion working with either lein figwheel or boot cljs with no success
this is using vim
anyone managed to get this working?
seems to be fine for standard clojure, but clojurescript seems to fail. i think it’s something to do with integration between fireplace and the clojurescript repl
i can evaluate the code, but just can’t seem to get the inline docs or code completion to work
sorry i didn’t realise there is a vim-fireplace channel, i’ll ask in there
I too had issues and I think the solution is in properly setting up piggieback, the middleware for interfacing clojurescript on an nREPL. I ended up using Cursive with a vim extension instead, but I hope you work it out. It should work out of the box.
hi, just read this
i got it all working today with vim
so let me know if you need any help
i had a lot of problems with the boot-cljs repl, but once i started using figwheel things got a lot easier
i now have automatic code complete working in neovim, using piggieback 🙂
using it to learn reagent, which seems to be a super nice library
I’m trying to use transit to send and receive messages between a JS and CLJS app. I’m using transit-js for JS and transit-cljs for CLJS. Do I need to write custom deserializers for receiving EDN in JS as JSON?
Reading on the JS side is returning a TransitArrayMap. I was expecting JSON 😕
transit represents a lot of things json can't, I think you'll need to make your own translator
if everything needs to be a subset of json, you don't need transit and you can just use a json formatter directly
@noisesmith What would you suggest?
I’m communicating with a JS app that expects JSON, CLJS app is sending EDN with keywords, otherwise nothing fancy. I thought clj->js was slow, so introduced transit to avoid that
clj->js is slow, but if you know the overall shape of the data you need to make, you can do something much more performant
the other option is for the js to use the actual cljs data types
if you are crossing the network then yes transit will probably be faster. if not clj->js should win.
To clarify I’m doing that operation as well. Just trying to have a JS and CLJS communicate with data as performantly as possible, each with their native data formats (EDN for CLJS, JSON for JS)
Hm ok. It’s across a webworker with postMessage/onmessage
Ok. Phew 🙂. So only problem I think I’m having is that JS side transit-js/read returns some transit-js object, not JSON. Trying to get to JSON
the string is json before you call transit-js/read, if you use :json or :json-verbose as the format
it might not be easy to use json, but it will definitely be json
Ah. Ok. So that gets somewhere. If the CLJS side encodes in :json-verbose I get vanilla JSON that I can parse on the JS side
I thought :json was faster, so I was using that. The raw message I receive with it is transit encoded. Reading it with transit-js produces a transit Javascript object, which I’d then need to turn into JSON…
Should I call it good enough with using :json-verbose?
the raw message the :json encoding creates is valid json, but constructed in such a way as to optimize message size and memory usage
rather than being an inutitive mapping of the input
it really depends on what your performance and space needs are, but I'd suspect using :json-verbose would be ideal
Thanks for your help
@goldsmith.tee It would be interesting to know whether the patch in https://dev.clojure.org/jira/browse/CLJS-2529 resolves your Java 9 issue. Details on trying a patch are here http://blog.fikesfarm.com/posts/2016-02-22-trying-clojurescript-paches.html
Hi, I’m trying to use the npm-deps feature per this post (https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules) I’m using the aws-amplify library. The build seems to be fine, a package.json was created, I see the lib in node-modules, etc. I’m running into an issue when I try to require the module. In both requires’s in the repl and :require in namespace declarations, I’m getting the assertion failure regarding “aws-amplify” not being a symbol. I’ve seen similar issues discussed in the archives, but it’s not clear what the solution is. I’m on 1.9.946, most of the stuff I saw discussed the issue in the context of earlier versions
@U380J7PAQ I’ve not had good luck with that feature. It’s very hard to figure out what is wrong when it doesn’t work. I’d suggest either using foreign-libs or, if you are importing a lot of stuff via npm use shadow-cljs as that allows you to just use npm or yarn directly. I’ve had a really good experience with shadow
ok thanks, that’s great to know. I saw something about shadow-cljs, will check it out I know this is a knotty problem and lots of ‘clogenuises’ are working it, but it’s kinda hard to get a clear read on what’s best like ‘now’ lol Thanks again
ClojureScript master
should also have much improved support for Node packages (though might also have regressions)