This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-14
Channels
- # adventofcode (62)
- # beginners (78)
- # boot (26)
- # boot-dev (9)
- # cider (73)
- # cljs-dev (33)
- # cljsrn (36)
- # clojure (159)
- # clojure-android (1)
- # clojure-austin (1)
- # clojure-greece (79)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-russia (11)
- # clojure-spec (33)
- # clojure-uk (26)
- # clojurescript (107)
- # core-async (22)
- # core-logic (12)
- # cursive (16)
- # datomic (13)
- # devcards (5)
- # duct (36)
- # emacs (4)
- # figwheel (3)
- # fulcro (107)
- # graphql (171)
- # hoplon (27)
- # instaparse (24)
- # jobs-discuss (34)
- # juxt (3)
- # lein-figwheel (1)
- # leiningen (8)
- # lumo (11)
- # off-topic (9)
- # onyx (79)
- # parinfer (1)
- # pedestal (75)
- # re-frame (27)
- # rum (1)
- # shadow-cljs (11)
- # spacemacs (20)
- # specter (17)
- # unrepl (96)
Hey, all. Trying to work out the conversion of this JS to CLJS: $(function() $("#datepicker").datepicker();});
Has anyone managed to get React Router to work via NPM imports?
@blake.watson code seems correct, except for the #
-`.` swap. could it be simply that?
@vemv Oh, I'm switching between ID and class selectors, is all. I want $(function() $(".datepicker").datepicker();});
I don't think it's working. I've got two problems whenever I do something like this: I don't know if I have the js->cljs transliteration right, and I don't know if it's actually being called, or called at the right time.
Do you? Like, I can put that js into the console after the page has rendered and it will work.
Wait, so the code DOES work. Cool. It's just a matter of figuring out where it should go, then.
So I have a react app, and it's building a screen from data with all the controls. I have it at the bottom of the render- function but that's not right, I guess.
A React-created element that responds to the $(".datepicker")
selector can exist/disappear as things are re-rendered
I'm trying to use a npm dep in my project and getting:
(fig-start)
Figwheel: Starting server at
Figwheel: Watching build - dev
Figwheel: Cleaning build - dev
Compiling "resources/public/js/app.js" from ["src" "dev"]...
Failed to compile "resources/public/js/app.js" in 32.571 seconds.
---- Exception ----
Assert failed: cljs.analyzer/foreign-dep? expected symbol got "graphql-voyager"
(symbol? dep)
---- Exception Stack Trace ----
I'm requiring ["graphql-voyager" :refer [Voyager]]
and using :npm-deps {:graphql-voyager "1.0.0-rc.10"} :install-deps true
on :compiler
profile.https://github.com/clojure/clojurescript/blob/9bcf0ff15247b37561d49e310cfb162bc0fc3156/src/main/clojure/cljs/analyzer.cljc#L2096 It's from this line
is there a clojurescript doc that describes why people keep using strings in require blocks?
https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
search for react-dom
I mean, that never looked right to me
@noisesmith idea might have come from https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html
@noisesmith Its in one of the guides
@alexisvincent yeah I found it here https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
but if cljs is complaining maybe you need a newer version?
its to support requires like tis “sdfsdfsdf/sdfsdfsdf”
@alexisvincent oh of course
I just used the "raw" cljs.build.api and get no erros. I think that it's a #figwheel problem
do you have the latest figwheel?
My figwheel/lein setup works.
I'm in trouble just with this tutorial https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules then I try to (require '["a-Npm-like-name" :as clj-name])
Yeah… but Im still getting errors. I cant import React Router. Keep getting errors
maybe not latest
@alexisvincent you could also check out lein with-profile cljsbuild deps :tree
and look at conflicts
or lein with-profile figwheel deps :tree
etc.
issues log in figwheel clearly shows someone requested this in a feature request issue, and the issue was closed marking as implemented
as of late june
hmm thanks. Thats helpful
It looks like it was an error with rum. Since React Router assumes a react instance and rum includes its own one
got a little bit further
ahh that sounds like something that could cause that issue
but hit something else now
Hey friends, I'm investigating compiling clojurescript with macros - is it possible to define a macro that exports a function to js-land via ^:export
metadata in a macro? Best I have for it right now is (defn (with-meta ~(symbol fn-name) :export) [] ...)
since I hear reader macros are no good in macros.
nm sorry, I clearly didn't read defn specs closely enough - for anyone else wondering, (defn ~(symbol fn-name) {:export true} [] ...)
did the trick just fine.
question guys: what is your choice of charts library to work with a frontend in reagent ?
recharts is pretty good React lib built on top of d3 http://recharts.org/#/en-US/
Did you try http://www.reactd3.org/ ?
Guys, How is that possible with production build with npm modules ? I can use it with dev profile, Clojurescript can find this module and add for me. But it comes to production build. It can’t.
@scknkkrer you're probably missing externs
oh, yeah you need to add :npm-deps to all builds
Yeah, my problem was, I just want to get optimized out from project. When I build min version of my project it gives error because npm-deps feature doesn’t work with advanced optimization profile option.
Does anyone know how to use normal React components nicely in rum. Without resorting to react/createElement nonsense
Hey, does anyone know why cljs has put!
but doesn't have take!
?
derpocious: in core.async? It has: https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async.cljs#L90-L103
@the-kenny thanks, do you know why this prints for <!
but not for take!
?
derpocious: check the documentation for take!
. In Javascript world you can't do blocking stuff at all, so you need to supply a function take!
will call when a value arrives on the channel
thanks. this might be dumb question, but is there documentation for cljs core.async?
besides the source itself
I was looking for it here: http://cljs.github.io/api/cljs.core/
Also, in the source for <!
all it does is throw an error? that doesn't seem right
(defn <!
"takes a val from port. Must be called inside a (go ...) block. Will
return nil if closed. Will park if nothing is available.
Returns true unless port is already closed"
[port]
(throw (js/Error. "<! used not in (go ...) block")))
@derpocious the go
macro rewrites the code inside (<! ...)
the function body is only there for if you call it outside of a go block
ah ok thanks
is there a difference between "port" and "channel"?
@derpocious a channel implements WritePort and ReadPort
@souenzzo just in case you haven't figured this out, the answer to your problem is that you can't used quoted symbols in a leinigen profile
@derpocious Your code should instead look like
(go
(>! a-channel "Hello, wworld!"))
(take! a-channel println)
hey @mfikes ... I was just trying to understand a post you made a few years back: <https://groups.google.com/forum/#!topic/clojure/34luqPyg6L4>
I'm trying to export a lib from CLJS to JS and require the JS side to see "normal" looking functions
(As an aside, FWIW, the ^:export
stuff on protocols is now mentioned officially at https://clojurescript.org/reference/advanced-compilation#access-from-javascript)
Yes, @hagmonk if you use ^:export
, this makes it possible for JavaScript to make calls into your code when :advanced
is applied.
I'm using optimization: whitespace right now for a couple of reasons, but on the JS side even with ^:export I still see myns$module$IDatasource$testDataSource$arity$1()
Well, ^:export
doesn't change your code. It only adds additional aliases that point into your optimized code. But it is interesting that you are running into this under :whitespace
because in that case ^:export
is not needed at all. Your functions should be available in unaltered form.
@hagmonk thats how protocols looks. if you want actual JS functions you need to define the functions on Object
ah, I think I'm misunderstanding what :export is supposed to provide ... really it's just "don't munge"?
@hagmonk I need to run. But that Google groups post describes stuff that is open source. You can take a look for yourself how I did it: https://github.com/mfikes/goby
Cool, I'll pick this up again later, I also have to run. thanks @mfikes and @thheller!
@hagmonk FWIW, if you define the example protocol on the ClojureScript site:
(defprotocol IFoo
(^:export bar [this])
(baz [this x])
(^:export quux [this x y]))
Then (js* "cljs.user.bar")
"exists"@hagmonk Furthermore:
cljs.user=> (defrecord Foo [] IFoo (bar [this] 1))
cljs.user/Foo
cljs.user=> (def f (->Foo))
#'cljs.user/f
cljs.user=> (js* "cljs.user.bar(cljs.user.f)")
1
@mfikes myns$module$IDatasource$testDataSource$arity$1()
is the property on the actual object, not the dispatch fn. so I think he was looking to export a propery that external JS can call.
@thheller Could be. @hagmonk initially referred to a question I had asked and then answered, and that question was about exporting functions defined by protocols.