This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-09
Channels
- # bangalore-clj (1)
- # beginners (158)
- # boot (8)
- # cider (9)
- # cljsjs (9)
- # clojure (169)
- # clojure-austin (1)
- # clojure-denmark (1)
- # clojure-dusseldorf (5)
- # clojure-italy (9)
- # clojure-losangeles (2)
- # clojure-russia (31)
- # clojure-spec (53)
- # clojure-turkiye (1)
- # clojure-uk (56)
- # clojurescript (145)
- # cursive (72)
- # datascript (4)
- # datomic (3)
- # duct (121)
- # events (9)
- # figwheel (1)
- # fulcro (46)
- # graphql (4)
- # hoplon (16)
- # jobs (1)
- # jobs-discuss (4)
- # leiningen (16)
- # lumo (5)
- # off-topic (38)
- # om (1)
- # om-next (5)
- # onyx (104)
- # parinfer (5)
- # re-frame (106)
- # reagent (1)
- # ring-swagger (3)
- # rum (1)
- # shadow-cljs (235)
- # slack-help (4)
- # unrepl (25)
- # yada (9)
I tried a simple module like dialog in https://www.npmjs.com/package/dialog and tried to use like (:require ["dialog" :as dlg])
or (:require dialog)
but got compiler error
I thought it was easy like in https://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/
I know about the 300ms delay. I kn,ow about hammer.js Is there some cljs package I ca just require, and have all cljs events not have 300ms delay?
@fabrao I got an error because I had an old node version, which version of node are you on?
I was on an ancient one, don't remember which, and upgraded to 8.6.0, which solved my problem. Yours doesn't seem that old, but I dunno. Maybe post the error you're getting. Your :require
seems ok.
java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "dialog" (symbol? dep)
have you seen this? @madstap
Yes I have. I get that error a lot. When I do rm -r node_modules
it goes away ¯\(ツ)/¯
I added "node_modules" to :clean-targets
in my project.clj
, which feels horribly hacky, but it's convenient.
I don´t know what is the problem, the problem is the same after removing node_modules and starting it again
Yeah, I'm on linux so it might be a windows issue. What works for me is just spamming the delete node_modules command. I don't actually understand this stuff, so let's hope someone that does sees this and can help.
So, I got another question: I'd like to do some basic dom manipulation and I'm not ready to pull in reagent. I'd rather have something like jQuery. I looked at all the available solutions (jayQ, dommy, hipo, Domina) and it seems they all stopped being developed. Is there anything I'm missing?
@sebastian.goettschkes Depends on what you mean by "basic". If you need only API that's uniformly supported within all modern browsers, you don't really need any library - just use JS interop. That was the reason why I stopped using Domina and didn't turn to any other library - they all offer a thin layer that in the end doesn't really give anything, at least with my usage.
@p-himik What I need is some toggling of css classes, logic on form submit, ... It's a prototype so I don't want to invest in a big framework upfront. In the past I just plugged in jQuery and I was now looking for something more in line with Clojurescript
there is a native web api for that now: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
and for the form submit: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
but also, a lack of activity on a clojure(script) project isn't necessarily a bad thing: it often just means it's stable
I'm giving a shot at the new :npm-deps
, trying to pull https://github.com/s-yadav/react-meta-tags :
:compiler {
...
:install-deps true
:npm-deps {:react-meta-tags "0.3.0"}}
I get Error: Can't resolve 'react' in '.../node_modules/react-meta-tags/lib'
When I look at package.json for react-meta-tags:
"peerDependencies": {
"react": "^0.14 || ^15.0.0 || ^ 16.0.0",
"react-dom": "^0.14 || ^15.0.0 || ^ 16.0.0"
},
"dependencies": {
"prop-types": "^15.6.0"
},
Looks like peerDependencies
are not being pulled (not in node_modules)?@fbielejec peerDependencies are not meant to be pulled. they're for a user of a library to install themselves: https://docs.npmjs.com/files/package.json#peerdependencies
fair enough; so I'd rather add them
:npm-deps {:react "16.0.0"
:react-dom "16.0.0"
:react-meta-tags "0.3.0"}
or add them as a dependency for lein npm? Or perhaps doesn't matter, as long as they end up in node_modules? I believe npm install would print a warning if peer deps are absent - it'd be helpfull is it was preserved in the context of :npm-depshttps://github.com/clojure/clojurescript/commit/d717b4edea074fcfd3e718a6134238ba26f76f82 I don't know how web web browsers work -- is there some flag to opt-out of ES6 to make old code work again?
I have some cljs things compiled decades ago and I would like them to start working again without recompiling if that's easy for some reason
@gfredericks there is not
man I had the impression browsers were pretty committed to backwards compatibility
oh, they are. but js engines are a black box to us, so any changes they do make to them are non-negotiable
oh I wasn't asking about a flag in CLJS; I was thinking some kind of html attribute on the script tag or something
e.g., you can opt-out of HTML5, correct?
I'm not asking about opt-ing in to HTML5
I'm talking about running really old code
on modern web browsers
e.g., html from 20 years ago still renders okay afaik
so I was wondering if javascript from 4 years ago also had some hope of running
I was checking how to change the current location in clojurecsript
This according to http://clojurescript-reference.mattho.com/javascript/index.html
should work in theory (aset js/window.location "location" "
but doesn't seem to do anything and not failing either, any idea?
@sundarj's suggestion is the correct approach. If, for some reason you want to use a string for a property name
(goog.object/set js/window "location" url)
would be correct, while using aset
is incorrect (being meant only for setting values in JavaScript arrays).@gfredericks JS isn't a lisp, so any new syntax/semantics will be backwards-incompatible. HTML on the other hand, is quite lispy in that you can continually add new elements to it without changing the existing syntax/semantics
@sundarj but you could imagine having different versions of js available in the browser, same as html
@gfredericks you could, and i think that would be a far better way of doing things - but, alas, that is not the case
Javascript is the future!
@sundarj thanks!
I have the exact same problem: https://stackoverflow.com/questions/34706153/how-to-override-onload-methods-in-clojurescript
My .-onload
function is not called.
(.addEventListener thing "load" (fn [e] ...))
.. using set!
will override any other.
Hmm… still not working. Maybe the error is somewhere else:
(.addEventListener img "load" (fn []
(debug "drawing the image")
(.drawImage ctx img 0 0)))
(set! (.-src img)
(str "data:image/svg+xml;charset=utf-8,"
svg-string))
Maybe I should try https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas
uhm why do you need the load event? it isn’t loading anything if you set the source?
Does anyone know how create a view function in Re-frame that returns HTML instead of Hiccup? My app displays a graph that is generated HTML from the backend. I'm wondering how to dump that into my page...
Cool, thanks!
@borkdude What is img
in your code? I have something like this working for webp detection. Though I'm using (gobj/set img "onload"...)
Apparently it doesn’t like something in my svg. Going to debug that. Thanks for now folks!
Question: How do I specify the clojurescript build id if I use :hook
? I have 3 different clojurescript build maps and I'd like to specify which one to use when building the uberjar
@scknkkrer not easy to answer, depends on which tools do you prefer to use
nevermind, consult your favourite tool's documentation: https://github.com/technomancy/leiningen/blob/stable/doc/DEPLOY.md
maybe this could help: https://github.com/clojars/clojars-web/wiki/Tutorial
Generating an key with gpg and write it down in project.clj as :signing value. Right ?
@scknkkrer I personally put this into ~/.lein/profiles.clj
because it is used for all my libs
something like this: https://gist.github.com/darwin/06f9154e97e6c58f735c46dad1232a9b
this will ensure correct specific gpg key is used and maybe some library metadata is properly set, but I'm no clojars expert, this has been working for me
you should inspect generated jar file to be deployed (which is just a zip file with some well-defined structure), inspect xml files there and make sure they look ok, especially make sure you did not include there some garbage
Is there any template eleminate all those problems ? I just want to create basic --really basic-- library for clojurescript.
then distribute it in source form, and instruct library users just copy sources into their src folders (or symlink them / whatever)
(defproject your-group/the-thing "0.0.1"
:description "FIXME"
:url "FIXME"
:license {:name "Eclipse Public License"
:url ""}
:dependencies
[[org.clojure/clojurescript "1.9.946" :scope "provided"]])
Ok. Thanks @darwin. I am digging down a little bit. If I can’t. I will do as you said.
I will dig about leiningen project structure a little bit. I think I am not good enough.
I know this is weird, but I generate a key for me and set this. When I deploy; gpg: signing failed: Inappropriate ioctl for device. Error returned twice.
that might mean you have the CLI version of gpg installed and are using leiningen
a workaround is to use the same gpg key for something else so it is in fresh cache, a fix is to use a GUI gpg, or fix lein to share stdio with gpg when shelling out
I think the problem is my name. Contains non-ascii character. The GUI of gpg solved the problem well. Thanks again @darwin.
it’s not your name, it’s the fact that lein can’t let gpg prompt for user input like passwords
hi, I'm using transit-cljs
for providing bigdecimals in cljs. I need to turn those bigdecs into strings and back, but I'm having problems transforming a bigdec into a string
as per http://increasinglyfunctional.com/2015/11/12/transit-clojurescript-big-decimal/ I wrote this:
(cljs.reader/read-string (.-rep my-bigdec))
but it looks slightly ugly, anyone knows a better way?
@noisesmith thank you too.
@joelsanchez wait - you are asking read-string to consume a float and you want that to return a string? I’m confused
read-string
consumes a string
the .-rep
value is a string
but you said you wanted to create a string
ah sorry...yes, .-rep
is enough
it just looks sort of internal, but yes, I can just use it
it's a pity they didn't implement the str
fn
anyway, read-string is a big tool for such a specific task - you can also use (js/Number. (.-rep my-bigdec))
, or something more like (-> my-bigdec (.-rep) (js/Number.))
👍 I'll go with that, and I'll hide the .-rep
uglyness and forget that it exists 😛 thanks
I’m trying to use the fetch
API https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API within CLJS. It uses Headers (https://developer.mozilla.org/en-US/docs/Web/API/Headers) which in turn returns iterators. Is there a simple way to treat iterators as seqs in CLJS?
Why you choose fetch over https://google.github.io/closure-library/api/goog.net.FetchXmlHttp.html ??
I can always write some custom code using .done
and .next
, but perhaps there is some way I’m missing?