clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Karol Wójcik 2021-03-11T08:01:23.294400Z

Does anyone know any tools for generating api documentation out of source code for #clojurescript which are not either codeina or codox. The tool should would work well with cljc & shadow-cljs style of requires.

simongray 2021-03-11T10:12:37.294600Z

There's Dynadoc by Zach Oakes.

simongray 2021-03-11T10:12:55.294800Z

Not sure if that fits the bill.

Karol Wójcik 2021-03-11T13:01:50.295400Z

Thanks @simongray! Actually not really. The best option for me would be to run clj-doc so that it would generate html files.

fsd 2021-03-11T15:08:24.297800Z

Hello there, I am JS dev, new to Clojure world. I have this function in JavaScript for mapbox and need help converting it to clojurescript. import data from './data.json'

const featuresLst = data.map(
    park => ({
        "type": 'Feature',
        "geometry":
        {
            "type": 'Point',
            "coordinates": [park.Longitude, park.Latitude]
        },
        "properties": {
            "marker-symbol": getImage(park),
            "title": [park.Name]
        }
    }));

p-himik 2021-03-11T15:12:24.297900Z

You can't import data like that, but there are other means to achieve the same: https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745 Even if you're not using shadow-cljs, you can still use the same approach via macros. The rest you can do via JS interop. There's a section for that in this cheatsheet: https://cljs.info/cheatsheet/

p-himik 2021-03-11T15:14:18.298200Z

This FAQ for JS devs might also be useful: https://clojurescript.org/guides/faq-js

fsd 2021-03-11T15:15:22.298400Z

Ah I see @p-himik thanks for the helpful info.

👍 1
fsd 2021-03-11T15:16:59.298700Z

I tried this website https://roman01la.github.io/javascript-to-clojurescript/ for converting this piece of code but some reason it just does not process this.

const featuresLst = data.map(
    park => ({
        "type": 'Feature',
        "geometry":
        {
            "type": 'Point',
            "coordinates": [park.Longitude, park.Latitude]
        },
        "properties": {
            "marker-symbol": getImage(park),
            "title": [park.Name]
        }
    }));

p-himik 2021-03-11T15:31:13.299Z

Wrap the body of the arrow function in {return ...;}.

p-himik 2021-03-11T15:32:50.299200Z

Huh, doesn't work with a "full" object but works with just {}. Eh, don't rely on this thing. Just go through the guides and convert it by hand.

👍 1
p-himik 2021-03-11T15:33:10.299400Z

Or use the tool, but only for some small chunks of code - not for the whole thing.

👍 1
fsd 2021-03-11T16:00:23.299800Z

Thanks for taking your time out 🙂

DoubleU 2021-03-11T22:37:07.301700Z

I posted this in the beginners room, but I think it might be better to have it here: Hi All, bit of a newbie question here, but I have a form component in my clojurescript, and that component contains a form-input as a child (code below).  I’m trying to figure out how to dispatch an event back out to my component when the `on-blur` event is fired but not exactly sure how. With something like Angular, from within the component I could use the .emit(), in React, I could do something like onClick={someMethod} which would then call a method in my parent, but not sure how to do this in clojurescript (or if this is even possible).  Can someone provide some direction?

[form-input
          (utils/merge-fn-props {:on-input #(reset! value (-> % .-target .-value))
                                 :on-focus #(reset! focus? true)
                                 :on-blur #(reset! focus? false)}...

p-himik 2021-03-11T22:51:03.301800Z

Saying "do it in ClojureScript" is like saying "do it in JavaScript". But you mention Angular and React, and the most probable corresponding thing in the ClojureScript world is Reagent. Almost always, you can do the exact same thing in Reagent that you can do in React. If you still can't figure it out, post the code that includes the parent component.

joelittlejohn 2021-03-11T23:54:01.308200Z

I’m trying to override toString for a value so that I can get a custom string when I use the str function on it. I can see that people in the past have recommended just creating a type and overriding toString like you would in Clojure: https://groups.google.com/g/clojure/c/ARqsbic3F_8 https://stackoverflow.com/questions/48703654/convert-custom-type-into-string This seems to work great if I do (str x) , but if I do (str [x]) then the overridden toString is not used (and I see #object[something.core.MyType] instead. Is there something special about str for collections in ClojureScript that means it does not just perform str on each item inside?