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?
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.
Maybe #re-frame and/or #react channels will have folks with more knowledge @dumrat?
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
?@jr0cket i did have that option, but i wanted to get a deeper understanding of symbols and evaluation in clojure. thanks.
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...
"+" -> +
for a high level overview http://dataintensive.net is very good
((resolve (symbol (first op))) 4 3)
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?@delaguardo that's what i needed. thanks.
It's not easy with Spec 1 but it will be easier with Spec 2 -- although that isn't ready for production use yet.
Thanks. I hadn’t thought of that!
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
@mark354 there is also Malli which just hit 1.0 https://github.com/metosin/malli
Wow. That looks really interesting. Thanks for the pointer. Looks like a better way to both specify AND document your structures.
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:
{: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")@yubrshen this line
:dev {:extra-path ["config/dev" "env/dev"]}
should be :extra-paths
If you're using aliases for :dev
, :test
, then you wouldn't need "config/dev"
in :paths
I think?
@seancorfield Thanks! Amazing you know the answer before my finishing my question!
And then when you build for prod? Or is that just the default?
I hope so, after your correction.
@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}"]}
}}