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.
There's Dynadoc by Zach Oakes.
Not sure if that fits the bill.
Thanks @simongray! Actually not really. The best option for me would be to run clj-doc so that it would generate html files.
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]
}
}));
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/
This FAQ for JS devs might also be useful: https://clojurescript.org/guides/faq-js
Ah I see @p-himik thanks for the helpful info.
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]
}
}));
Wrap the body of the arrow function in {return ...;}
.
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.
Or use the tool, but only for some small chunks of code - not for the whole thing.
Thanks for taking your time out 🙂
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)}...
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.
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?