This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-28
Channels
- # bangalore-clj (1)
- # beginners (67)
- # braveandtrue (179)
- # cider (28)
- # cljdoc (1)
- # clojure (132)
- # clojure-conj (3)
- # clojure-dev (1)
- # clojure-finland (6)
- # clojure-nl (2)
- # clojure-russia (6)
- # clojure-spec (19)
- # clojure-uk (62)
- # clojurescript (90)
- # clojutre (5)
- # component (2)
- # cursive (30)
- # data-science (1)
- # datomic (42)
- # duct (9)
- # emacs (1)
- # figwheel-main (158)
- # fulcro (57)
- # funcool (3)
- # hoplon (1)
- # jobs (17)
- # mount (38)
- # off-topic (15)
- # re-frame (53)
- # remote-jobs (2)
- # schema (11)
- # shadow-cljs (299)
- # spacemacs (25)
- # specter (2)
- # tools-deps (54)
- # vim (11)
- # yada (6)
With Leiningen is there a place you can put a user.cljs
file with functions that will get automatically loaded when you start the repl?
Hi, I have asked the same question in #beginners yesterday. I was told check here. I am trying to copy content to clipboard when a list item is clicked. I found a solution in javascript, which i tried to convert to clojurescript and failed.
var copyText = document.getElementById("myInput");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("Copy");
when i try to do something similar in clojurescipt it fails
app:emoji-search-clojurescript.core=> (.getElementById js/document "emoji-title-100")
#object[HTMLParagraphElement [object HTMLParagraphElement]]
app:emoji-search-clojurescript.core=> (.select (.getElementById js/document "emoji-title-100"))
#object[TypeError TypeError: document.getElementById(...).select is not a function]
How do i select the value and then copy it to clipboard.i don't think you are getting the right element. #object[HTMLParagraphElement [object HTMLParagraphElement]]
I was using that javascript solution as an example. I do not have an input element, i am trying to copy a paragraph element on click.
@dnolen Without those lines, the bundle is generated, with all the right code, but it's not exported or assigned or made available in any way. The libraryType
is essential for specifying that; it defaults to "var"
, meaning it uses the library
value to generate var foo = { ... };
(assuming library: "foo"
). In this case, without the library
value, no var is generated. For CommonJS requires in a way which generates exports["UI"] = { ...}
, I set the values shown in the paste.
@jeaye it looks to me like you are missing the window.React = React;
equivalents? ie. you are supposed to manually ensure the variables created instead of having the index
export them. libraryType
may however be useful. https://clojurescript.org/guides/webpack#javascript-dependencies
this may of interest as well https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html
Is async/merge
+ go-loop
the accepted idiom for firing a bunch of cljs-http requests and collecting their results all at once?
@danielstockton my opinion: 10x simpler to use js/fetch & js/Promise.all
what you mention sounds like too many layers to me: core.async wraps cljs-http wraps goog.xhrio wraps XMLHTTPReqeust
plus js/fetch is the better api — again, in my opinion
cljs-http handles transit transparently though.
(-> (js/fetch url) (.then #(.text %)) (.then #(transit/read %)))
easy as pie
Yeah, fairly nice. I guess I can create my own wrapper around fetch easily enough.
That doesn't tie me to core.async
@danielstockton today I published a demo SPA based on the "embrace the host" principle: https://github.com/pesterhazy/cljs-spa-example - feel free to take a look
Cool, thanks
Is there a reasoning why Hiccup and Hiccup inspired libraries decided to use vectors to represent HTML instead of maps?
Tagged vector:
[:div {:display :block} [:span "hi"]}
The alternative would be:
{:tag :div, :attrs {:display :block}, :children [{:tag :span, :content "hi"}]}
I noticed that the arglists in this code seem to be of type clojure.lang.Cons in contrast to the usual list that defn
constructs. Is this expected? Maybe the way the arglists metadata is constructed is wrong?
~(with-meta fname {:doc doc-string :added (:added validator-meta-data) :arglists `'(~args)})
code is from here btw: https://github.com/markwoodhall/clova/blob/a3205fbfa72bb644f915e9e35fa6b3cc5c790a8d/src/clova/core.cljc#L43
Is anyone building a React/reagent based website that's not a SPA? I've been holding off on jumping on the SPA bandwagon because I felt it introduces a lot of complexity (local routing, etc.) that's maybe not worth the benefits.. But maybe I haven't take a close enough look. Is it crazy to build a reagent website that's not a SPA?
@thiru0130 that can be completely reasonable if it is complex enough. Though for simple needs, you can just use javascript, and avoid the complexity of needing compilation
Hmm I still want to use ClojureScript rather than Javascript. Most of the websites I build don't need a huge amount of rich interactivity on the client-side. The different pages/routes are often quite distinct in the functionality they provide and they usually only have the page header/footer in common!
Some pages do have a fair bit of dom manipulation though and it's definitely not easy/fun to do this with vanilla JS. I'd love to use reagent for these cases.
So I'd like to use a traditional client/server architecture and just use React whenever I need some DOM manipulation. Are there any big drawbacks to this approach?
@martinklepsch why would that make any real difference?
Some of codox‘ analysis code used a list?
predicate. changed that to seq?
and stuff is working fine. I guess I was just confused why the macro I linked creates a Cons
cell, regardless of whether that should make a difference
@jeaye it seems maybe you’re just skipping over what the ClojureScript Webpack guide recommends?
which is just exporting manually via window - I don’t really see what all this config via Webpack is doing for you
@thiru0130 that’s a pretty popular usecase - go for it 🙂
@jeaye if you're stuck on configuration, check out this demo app for an example of how to pull in NPM deps via webpack: https://github.com/pesterhazy/cljs-spa-example
@U0E1YG9M1 it's faster and clearer
just inherited a big cljs project with 1k lines of boot code and got confused why boot is so complex.
i just want to know opinions from experts. do you prefer boot, lein, or just shell scripts?
Ahh ok cool! I don't see this approach talked about much in blogs, etc. I figured it was almost taboo. Thanks @dnolen, @isak
@pesterhazy Thanks. I did figure it out yesterday, I just needed those two extra config options.
@dnolen I'm following what webpack recommends, in that case, from https://webpack.js.org/guides/getting-started/ Since I'm also transforming with babel, I need the config for the loader. I also don't care about minification, since Closure does all of that when it needs to. The rest of the config is stock.
@jeaye for the record I don't use those two options, libraryTarget and library, and it works fine
like I said - I just want to hear some rationale about why we should change our documentation
@jeaye yes, export via window https://github.com/pesterhazy/cljs-spa-example/blob/master/doublebundle/library.js
I don't see a lot of downsides to that style of doing things
@dnolen I see your reasoning for the window
approach now; as I mentioned in my original question, I'm not very familiar with the JS ecosystem, so this has been an exploration. However, based on comparing the two docs (CLJS and Webpack), I did things the Webpack way, since I'm using Webpack. That is, the way the Webpack home page and getting started and other docs and articles around Webpack suggest. None of them went through window
, but it appears to work well for this case as well. I wouldn't be able to say which is objectively better.
@dnolen With the understanding I have now, I do redact that the CLJS docs need to be changed, since I see how the window
approach is working. It's worth pointing out, however, that it veers from what seems to be the more idiomatic Webpack approach.
you’ll often want to shape the export so you get a sensible looking ClojureScript namespace structure
but yes, nothing wrong with dropping a note about how this is different from what you might infer from Webpack docs
but again the docs can be clearer here for those that might be looking at Webpack docs
We haven’t got this specific feedback before though - probably because people who use Webpack enough know it’s kind of a documentation nightmare
I remember puzzling over webpack's library
config option when I started out as well
People in this situation probably have more experience in the JS ecosystem, so they know what to look out for. I'm more a Clojurist who happens to be in the web world, for this project, and tries to avoid that aspect of things whenever possible. Having higher level documentation on "Doing this JS thing with ClojureScript" which uses Webpack would help; I can cook up a blog post on my findings, for those who're trying to accomplish a similar task without knowing exactly which tools to use.
In this case, using ClojureScript + re-frame with https://pagedraw.io/ -- which is awesome.
@jeaye assuming you did see this guide https://clojurescript.org/guides/webpack