This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-30
Channels
- # admin-announcements (24)
- # beginners (27)
- # boot (32)
- # cider (9)
- # cljs-dev (2)
- # clojure (96)
- # clojure-berlin (33)
- # clojure-dev (2)
- # clojure-gamedev (2)
- # clojure-germany (1)
- # clojure-italy (8)
- # clojure-japan (2)
- # clojure-russia (21)
- # clojurescript (178)
- # clojutre (3)
- # code-reviews (4)
- # core-async (58)
- # core-logic (22)
- # core-matrix (4)
- # cursive (10)
- # datomic (131)
- # events (9)
- # ldnclj (31)
- # off-topic (57)
- # onyx (9)
- # reagent (23)
I have an API that takes a list of string 'fields'. I want these to map to functions on the backend, which are then called, and the data returned. I want the fns to be evaluated only when the API call is made and the result thrown away after it’s sent back to the client. For this would it be idiomatic to store a map of fields to quoted fn calls (i.e., (def foomap {:field-1 '(some-fn-1) .. :field-n '(some-fn-N)}
, and then resolve the values as in (eval (:field-1 foomap))
? If this is madness, what's a better way?
maybe what you need is just (def foomap {:field-1 (fn[] (some-fn-1) .. :field-n (fn [] (some-fn-N)})
and then ((:field-1 foomap))
?
is this possible? in other words can I call the initialization function of my, say, Om app
ill direct this one @dnolen if he ever has a minute to read no worries if not though
but let me clarify that i understand that this is a weird use-case for cljs, its just that we have a monolithic enterprise angular app, and are only partway through the development wanting to try some CLJS in client-facing production
CLJS namespaces compile into google closure namespaces. So if your main CLJS namespace is my-app.core
, you can access the functions that ns provides by accessing window.my_app.core
e.g. http://nickol.us/om-identicon/ - in the developer console you can enter om_identicon.core
and it will return that NS in javascript
very cool. thanks @teslanick