Fork me on GitHub

What's the clojurescript equivalent of "abc"[1]?


I've just found charAt, that might work as a substitute, but I'm still curious if it's possible to do this?


there's (nth abc 1) but that just calls charAt


Can someone explain how to get a REPL to develop ?

David Pham07:11:20

Can you be more precise? Do you want to use cljs-ajax in a REPL, or use a REPL to contribute to the package?


I want to use a REPL to contribute. I only managed to do so by creating a blank Shadow CLJS project and copying in the source tree


do protocol names get munged by advanced optimizations?


ex cljs$core$IPrintWithWriter$

Ronny Løvtangen10:11:07

Hi. I have a question about global-exports. The example at uses a library which has a default export (React). But my library exports multiple named exports (`MarkerMap`, RouteMap, SetCoordinateMap and SetMultipleCoordinatesMap and no default export). My sollution so far:

{:file     "resources/lib/kartklient.js"
 :provides ["markerMap" "routeMap" "setCoordinateMap" "setMultipleCoordinatesMap"]
 :global-exports '{markerMap MarkerMap
                   routeMap RouteMap
                   setCoordinateMap SetCoordinateMap
                   setMultipleCoordinatesMap SetMultipleCoordinatesMap}}
then I can use it like this:
(ns dhp-client.helpers.kartklient
  (:require [reagent.core :refer [adapt-react-class]]
            [markerMap :as markerMap]
            [routeMap :as routeMap]
            [setCoordinateMap :as setCoordinateMap]
            [setMultipleCoordinatesMap :as setMultipleCoordinatesMap]))

(def marker-map (adapt-react-class markerMap))
(def route-map (adapt-react-class routeMap))
(def set-coordinate-map (adapt-react-class setCoordinateMap))
(def set-multiple-coordinates-map (adapt-react-class setMultipleCoordinatesMap))
Is there a way I can group markerMap, routeMap etc under a namespace, e.g. kartklient so that I can say [kartklient :refer [markerMap routeMap setCoordinateMap setMultipleCoordinatesMap]] instead of having markerMap, routeMap etc as top level namespaces?


Hello, i’ve got a warning when I evaluate this form: (cljs.core/MapEntry. 1 2)

------ WARNING - :fn-arity -----------------------------------------------------
 Resource: :1:1
 Wrong number of args (2) passed to cljs.core/MapEntry
It seems to work as intended, but I’m curious about the warning I’m using clojurescript 1.10.520


@pbaille why are you constructing it directy? it takes a third hash argument, you can pass nil


I like to use map-entries to represent linked things, not always in the context of a map


@thheller thank you for your help


does anyone know if I can include a plain javascript file as part of a clojurescript (`*.cljc`) release to clojars ? I am not entirely sure of how this would play on the consumer side … would they have to have the same configuration as my local one for it to work ? will it work at all ? :thinking_face:


@carocad You can include a deps.cljs file in a JAR which points to a JavaScript file (as a foreign lib)


(The ClojureScript compiler scans for deps.cljs)


nice, thanks for the info 🙂

Aleks Abla23:11:00

Quick question -- when we initialize-db, how and from where does the map get populated from?

Aleks Abla23:11:51

this is the event initialize-db command i have. wondering how it fills in the data. I guess I am wondering what happens behind this code?


I’m guessing you’re talking about using re-frame. There’s no magic; if you want to initialize the DB, you can create an event (like you have there) and have it return the map of initial data


it looks like that code there assumes there’s some db namespace that has a default-db var in it which has the map of initial data


and then somewhere else in the code, when it renders the application it must call (dispatch-sync [::initialize-db])

Aleks Abla23:11:18

awesome, thanks for the quick reply! so ultimately it's the dispatch that populates the db map?


when you want to initialize the db map, you dispatch the event to do so


the event handler should return the map you want to start with

Aleks Abla23:11:26

gotcha.. i am still trying to wrap my head around the initializing