Fork me on GitHub
#clojurescript
<
2019-11-13
>
datran04:11:10

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

datran04:11:34

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

dpsutton05:11:05

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

jgertm05:11:10

Can someone explain how to get a REPL to develop https://github.com/JulianBirch/cljs-ajax ?

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?

jgertm17:11:56

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

lilactown06:11:54

do protocol names get munged by advanced optimizations?

lilactown06:11:17

ex cljs$core$IPrintWithWriter$

Ronny Løvtangen10:11:07

Hi. I have a question about global-exports. The example at https://clojurescript.org/news/2017-07-30-global-exports 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?

pbaille10:11:21

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

thheller10:11:32

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

pbaille10:11:55

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

12
pbaille10:11:19

@thheller thank you for your help

carocad21:11:45

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:

mfikes22:11:33

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

mfikes22:11:56

(The ClojureScript compiler scans for deps.cljs)

carocad10:11:40

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?

lilactown23:11:57

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

lilactown23:11:24

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

lilactown23:11:49

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?

lilactown23:11:49

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

lilactown23:11:01

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