beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
dumrat 2020-10-24T05:09:07.439200Z

Trying to integrate https://github.com/nadbm/react-datasheet into a re-frame project. `(defn main-panel []   (let [name (re-frame/subscribe [::subs/name])]     [:div      [:h1 "Hello from " @name]      [(r/adapt-react-class ReactDataSheet)       {:data [[{:val 1} {:val 2}] [{:val 3} {:val 4}]]        :valueRenderer #(:val %)}]]))` This results in: <div><h1>Hello from re-frame</h1><span tabindex="0" class="data-grid-container"><table class="data-grid"><tbody><tr><td class="cell"><span class="value-viewer"></span></td><td class="cell selected"><span class="value-viewer"></span></td></tr><tr><td class="cell"><span class="value-viewer"></span></td><td class="cell"><span class="value-viewer"></span></td></tr></tbody></table></span></div> So no data is visible. Am I doing something wrong?

uosl 2020-10-24T11:49:46.448500Z

The valueRenderer function will get passed a JS object keyed by string. I think #(.-val %) will work, although it might break with closure advanced compilation, so I'd use cljs-oops #(oget % :val) instead.

seancorfield 2020-10-24T05:18:50.440600Z

Maybe #re-frame and/or #react channels will have folks with more knowledge @dumrat?

germ13 2020-10-24T07:12:27.442300Z

12:07 AM I have this:

(def op ["+" "-" "*" "/"])
((first op) 4 3)
This isn't working like I think it should. What I really want is to have it evaluate to this (+ 4 3) => 7. How do I achieve this given op?

germ13 2020-10-25T23:26:16.496400Z

@jr0cket i did have that option, but i wanted to get a deeper understanding of symbols and evaluation in clojure. thanks.

Marek Jovic 2020-10-24T07:14:38.444Z

Hello! I am searching for information on solutions on how to synchronize debit/credit transactions in Clojure. I am thinking to have a database as well. I want to have atomic operations. But maybe possibly have good performance. Please suggest any hints, articles, advice, books, etc...

vlaaad 2020-10-24T07:38:48.444100Z

"+" -> +

rakyi 2020-10-24T09:49:34.445Z

for a high level overview http://dataintensive.net is very good

💪 2
2020-10-24T13:42:31.453900Z

((resolve (symbol (first op))) 4 3)

Mark Wardle 2020-10-24T20:44:33.459800Z

Hi. Please may I ask some advice on clojure.spec.alpha? I’d like to generate the definition for the contents of a map from an existing vector I’m already using elsewhere. I naively tried this:

(def field-names ["PCD2" "PCDS" "DOINTR" "DOTERM" "OSEAST100M"
                  "OSNRTH100M" "OSCTY" "ODSLAUA" "OSLAUA" "OSWARD"
                  "MSOA11" "CALNCV" "STP"])

(s/def ::postcode-data (s/keys :req (map #(keyword (str *ns*) %) field-names)))
(s/describe ::postcode-data)
(s/valid? ::postcode-data {})
But as s/keys is a macro, it doesn’t evaluate the map. Is there an alternative approach? Do I have to write my own macro to get this to work?

germ13 2020-10-24T21:28:07.460500Z

@delaguardo that's what i needed. thanks.

seancorfield 2020-10-24T21:31:45.461200Z

It's not easy with Spec 1 but it will be easier with Spec 2 -- although that isn't ready for production use yet.

👍 1
Mark Wardle 2020-10-25T08:31:00.472200Z

Thanks. I hadn’t thought of that!

seancorfield 2020-10-24T21:33:03.462200Z

What we've done at work is go the opposite way: we start with the spec, then get its form and pull the list of keys out and use that programmatically @mark354

schmee 2020-10-24T21:57:16.462800Z

@mark354 there is also Malli which just hit 1.0 https://github.com/metosin/malli

Mark Wardle 2020-10-25T08:33:57.473700Z

Wow. That looks really interesting. Thanks for the pointer. Looks like a better way to both specify AND document your structures.

yubrshen 2020-10-24T23:26:56.465700Z

How to express in deps.edn with clj (CLI) to place a directory in classpath for yogthos/config? I have environment definitions at config/dev/config.edn thus I need to have config/dev on the classpath. I figured out the following deps.edn would work, but looks ugly:

yubrshen 2020-10-24T23:27:09.465900Z

{:paths
 ["src" "config/dev"]
 :deps
 {org.clojure/clojure           {:mvn/version "1.10.1"}
  com.datomic/datomic-pro      {:mvn/version "1.0.6202"} ; for peer API, found the version number in the Datomic software installation directory, and has to insall by bin/maven_install
  org.postgresql/postgresql     {:mvn/version "9.3-1102-jdbc41"}
  http-kit/http-kit                      {:mvn/version "2.4.0"}
  metosin/reitit                {:mvn/version "0.5.5"}
  yogthos/config                {:mvn/version "1.1.7"}}
 :aliases
 {:server {:main-opts ["-m" "grok.core"]}
  :dev {:extra-path ["config/dev"  "env/dev"]}
  :test {:extra-paths ["test" "config/test"]
         :extra-deps {lambdaisland/kaocha           {:mvn/version "0.0-529"}
                      lambdaisland/kaocha-cloverage {:mvn/version "1.0.63"}}
         :main-opts ["-m" "kaocha.runner"]}
  :socket-repl {:jvm-opts ["-Dclojure.server.repl={:port,50505,:accept,clojure.core.server/repl}"]}
  }}
by placing "config/dev" to the array of :paths, based on the tutorials, I should just to place with the aliases where I need the functionalities. But I could not get it working yet. (Edit: with help from @seancorfield, my mistake was the mis-spelling of "extra-paths" to "extra-path")

seancorfield 2020-10-24T23:28:27.466400Z

@yubrshen this line

:dev {:extra-path ["config/dev"  "env/dev"]}
should be :extra-paths

seancorfield 2020-10-24T23:29:19.467300Z

If you're using aliases for :dev, :test, then you wouldn't need "config/dev" in :paths I think?

yubrshen 2020-10-24T23:29:43.467900Z

@seancorfield Thanks! Amazing you know the answer before my finishing my question!

seancorfield 2020-10-24T23:30:05.468500Z

And then when you build for prod? Or is that just the default?

yubrshen 2020-10-24T23:30:10.468700Z

I hope so, after your correction.

1
yubrshen 2020-10-24T23:37:36.469900Z

@seancorfield Thanks a million! You're right. With your corrections, the following works:

{:paths
 ["src"]
 :deps
 {org.clojure/clojure           {:mvn/version "1.10.1"}
  com.datomic/datomic-pro      {:mvn/version "1.0.6202"} ; for peer API, found the version number in the Datomic software installation directory, and has to insall by bin/maven_install
  org.postgresql/postgresql     {:mvn/version "9.3-1102-jdbc41"}
  http-kit/http-kit                      {:mvn/version "2.4.0"}
  metosin/reitit                {:mvn/version "0.5.5"}
  yogthos/config                {:mvn/version "1.1.7"}}
 :aliases
 {:server {:main-opts ["-m" "grok.core"]}
  :dev {:extra-paths ["config/dev"  "env/dev"]}
  :test {:extra-paths ["test" "config/test" "config/dev"] ; added "config/dev" for 'clj -M:test --watch' to work
         :extra-deps {lambdaisland/kaocha           {:mvn/version "0.0-529"}
                      lambdaisland/kaocha-cloverage {:mvn/version "1.0.63"}}
         :main-opts ["-m" "kaocha.runner"]}
  :socket-repl {:jvm-opts ["-Dclojure.server.repl={:port,50505,:accept,clojure.core.server/repl}"]}
  }}