Fork me on GitHub
#beginners
<
2015-09-21
>
timfield02:09:36

(:require [mp.endpoint.property :refer [endpoints]]) cool, but how do I refer to endpoints as property-endpoints ( :refer :as doesn't seem to work simple_smile as I hoped )

timfield02:09:06

This looks to be what I was looking for [mp.endpoint.property :refer [endpoints] :rename {endpoints property-endpoints}]

Alex Miller (Clojure team)02:09:54

yes that's closer to what you want although fyi it's unusual to use :rename - more common to alias the ns and use the aliased form

Alex Miller (Clojure team)02:09:20

(:require [mp.endpoint.property :as property]) and then use property/endpoints in the code

timfield02:09:58

@alexmiller: Ok thanks, I'll do that.

Alex Miller (Clojure team)02:09:42

at the point of use in the code, you then have breadcrumbs that lead you back to the ns alias in the require and to the (same) named function in the external ns

Petrus Theron10:09:32

How do I export a cljs function so that normal JS can call it from the global namespace? E.g. Google Maps JavaScript API has a callback argument that is a global function name. I tried (defn ^:export initMap [] ...) and (aset js/window "initMap" initMap), but the fn does not seem to show up in window.initMap.

Petrus Theron10:09:10

Apologies - it does work. Needed a hard refresh simple_smile.

Petrus Theron11:09:29

I want to pretty print a cljs #js data structure, but (prn (js->clj some-form)) outputs an "unreadable form", which cannot be read by read-string. Is this expected? It seems to be object representations like these "viewport" #<((-33.9284489802915, 18.41180101970849), (-33.9257510197085, 18.414498980291455))>}. How can I format this to get any edn pretty printer to parse it?

Petrus Theron11:09:41

Or at least, I want to strip out these forms and look at the readable forms in the data structure.

dnolen11:09:56

@petrus round tripping JS objects for printing just isn’t generally possible

dnolen11:09:11

for exporting symbols see goog.exportSymbol

dnolen11:09:15

refer to the Google Closure Library docs

Petrus Theron11:09:20

Thanks. I got the export working.

Petrus Theron11:09:35

I don't need a round-trip, just to get rid of the unreadable forms.

dnolen11:09:06

there’s no baked in way to do that, you will need to handle this yourself

Petrus Theron11:09:22

Is there a fn that can test if a value is a #js object so that I can filter it out?

dnolen11:09:25

but note js->clj and cljs->js is backed by a protocol

dnolen11:09:43

there is no such test

dnolen11:09:57

you just have to know what’s in the thing that you want to print and handle it

Petrus Theron11:09:59

Any way to define a fallback print-dup fn for any type without it?

dnolen11:09:21

hrm dunno, haven’t thought about that

dnolen11:09:37

but the takeaway - there’s no “easy” way to accomplish this

Petrus Theron11:09:23

OK. In my case, it's just a really large nested map of returned Google Places and I could easily find the path I'm looking for if I could just pretty print it.

Petrus Theron11:09:40

I'll try a regex simple_smile

kyle_schmidt17:09:06

I work at a Python shop but I am am learning Clojure on the side and would like to pursue Clojure opportunities. What are the best ways to pursue Clojure job opportunities without having Clojure work experience?

danielcompton19:09:12

@kyle_schmidt: working on open source projects is one way of getting experience working on real world projects, but that's unlikely to be paid.