Fork me on GitHub

any lib recommendation to plot charts in cljs? I've found oz based on vega but it looks pretty complicated and quite overkill for what I want to do at the moment


I've used recharts and am quite happy with it


I ended up going with vega in the end, but thank you for the recommendation


Hey everyone, I’m learning clojure(script) 🌈 I’m tackling a small challenge and I’m a bit stuck in how should I write the on-change function of my text-input component. I think I need some help from you mates. ❤️ Here’s a screenshot of my code at this point.


#reagent would be a more suitable place. Also, it's much better to put the code itself here, and not a screenshot. Slack has two ways of embedding code blocks and one way of using inline code. With that said, you're calling reset! on value, but seems like value is actually a string. If you need to change only value and not the rest of the input fields, remove the outer atom and wrap the value strings in their own atoms. A related thing - the way you wrote the code, those ratoms are (re)created upon namespace evaluation. It means two things: • Re-rendering will not change inputs' values. So even if you unmount the whole component and then add it back, the values will stay the same. Could be changed by creating those atoms in the components themselves, maybe their parent. reagent.core/with-let and form-2 and form-2 components are useful here • Code reloading will reset those values back to their initial value. Can be changed with defonce


And if you do want to store the whole state of everything in a single atom, you should use swap! instead, pass the whole state atom to it, and use update-in with the right path to change the relevant value. But at that point, you will be reinventing the wheel that re-frame has implemented quite some time ago.


Thanks mate! That explains a lot. Next time I’ll paste the code in the reagent channel. Thanks for the suggestion!

👍 3

Hi, trying to get started with cljs, thought I'd try re-frame but don't want to create a bunch of files by hand, found this


but it's not clear how to install this template so that leinginen will see it - I found some advice to put is in the classpath, but CLASSPATH=~/re-frame-template lein new re-frame-template myapp doesn't work, it complains that I set the classpath var, then fails to find the template. I've been bouncing around between documentation and blog posts but nothing seems to connect the dots


how do I install a template so I can start a re-frame project?


Have you read the README of the template project?


In general, you don't install templates yourself. They exist as jars in public repositories. Lein knows how to handle them.


yes, oh I shouldn't have added -template


Hi, is there any ClojureScript library like, that can run in node and browser?


It's not that often that you see a CLJS library doing the same thing as an existing JS library is already doing, given that CLJS/JS interop is rather smooth.


To be clear, I have no clue whether such a library exists. But if there's already isomorphic-fetch that you probably know how to use, I'd just use it without even looking for an alternative.


Right, I saw a few like cljs-ajax and cljs-http, lambdaisland/fetch, but they all for the browser, I thought that there should be something like this already.


    .then(function(response) {
        if (response.status >= 400) {
            throw new Error("Bad response from server");
        return response.json();
    .then(function(stories) {
(ns your.ns
  (:require ["isomorphic-fetch"]))

(-> (fetch "//")
      (fn [response]
        (if (>= (. response -status) 400)
          (throw (js/Error. "Bad response from server"))
          (.json response))))
      (fn [stories]
        (.log js/console stories))))


Just add ^js in front of response to make sure that .-status and .json are not munged during :advanced optimizations.


Great, thanks!!! I also want to connect it with transit, to provide better ClojureScript interrop, perhaps I can create a wrapper lib.