This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-14
Channels
- # beginners (33)
- # boot (38)
- # clara (21)
- # cljs-dev (1)
- # cljsjs (2)
- # cljsrn (12)
- # clojure (230)
- # clojure-argentina (1)
- # clojure-brasil (3)
- # clojure-dusseldorf (4)
- # clojure-france (9)
- # clojure-italy (1)
- # clojure-russia (123)
- # clojure-spec (46)
- # clojure-turkiye (1)
- # clojure-uk (60)
- # clojurescript (83)
- # core-async (6)
- # cursive (10)
- # datascript (19)
- # datomic (28)
- # defnpodcast (1)
- # emacs (7)
- # figwheel (7)
- # fulcro (29)
- # leiningen (29)
- # lumo (9)
- # off-topic (14)
- # om (1)
- # onyx (25)
- # pedestal (1)
- # protorepl (3)
- # re-frame (10)
- # reagent (41)
- # ring-swagger (11)
- # shadow-cljs (10)
- # testing (5)
- # unrepl (3)
- # vim (3)
@rinaldi Another idea, for kicks... IF each sub-vector of the data structure is regular in the following form:
["question" "x%" "y%" "z%"]
then
(defn flatten-questionnaire [qs]
(->> qs flatten (partition 4)))
Will always work, for any level of nesting, because order is guaranteed in the qs
vector. The result is also a sequence in which order is guaranteed.Also some spec based pattern matching @rinaldi (`coll` being your snippet):
(require '[clojure.spec.alpha :as s])
(s/def ::col (every-pred string? #(not (re-find #"(?i)(question|display)" %))))
(s/def ::row (s/coll-of ::col :kind vector?))
(filter #(s/valid? ::row %) (tree-seq vector? identity coll))
It has the advantage to work for any nested level and independently from display/question positioning.Hi, has anyone used leiningen repl before to load a namespace?
I posted my issue in the leiningen room. Would appreciate some help. If only this all was as easy as npm 😁
@derpocious did you load the namespace? did you use the in namespace keyword?
how does one call a clojurescript function from javascript that is not in namespace.core?
@javazquez since clojurescript compiles to javascript you can use the ^:export
metadata flag to make it available to your javascript code. like if you had cool_code.cljs
that looked like this (ns cool-code) (defn ^:export chill [] "Im chillin")
then you could call it from your javascript code like this cool_code.chill()
Hi @gdeer81 Thanks for the reply. That doesn't seem to work for me (ns scrappy-guitar.google-aws) (defn ^:export signin-callback [] (js/console.log "testing" )) chrome console >scrappy_guitar.google_aws.signin_callback() VM5442:1 Uncaught TypeError: Cannot read property 'signin_callback' of undefined at <anonymous>:1:27
in the chrome console you can see your compiled clojurescript code in the "sources" tab?
if I modify the file, I see the following in chrome console not required: ("resources/public/js/compiled/out/scrappy_guitar/google_aws.js")
@gdeer81 I successfully invoked that function from the repl and now it works in chrome console
Do I have to make reference to it within my core.cljs file? If I do that, I notice that the file then gets put into the sources directory
seems that I was on the right track https://github.com/bhauman/lein-figwheel/issues/202
Thanks for helping me work through. I never knew about looking at the compiled sources 🙂
@javazquez yes there is even source mapping so you can trace a js error back to the cljs source. Everyone that works on clojurescript and all the tools around it are my heroes for taking something that used to make me cry myself to sleep at night and turning it into a tolerable development experience.