This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-08
Channels
- # announcements (1)
- # asami (3)
- # babashka (51)
- # beginners (86)
- # chlorine-clover (1)
- # cider (18)
- # clara (5)
- # clj-kondo (6)
- # cljsrn (6)
- # clojure (2)
- # clojure-europe (18)
- # clojure-uk (1)
- # clojurescript (57)
- # clojureverse-ops (2)
- # code-reviews (9)
- # cryogen (11)
- # depstar (5)
- # jackdaw (2)
- # malli (8)
- # nrepl (2)
- # off-topic (66)
- # practicalli (3)
- # reitit (6)
- # shadow-cljs (83)
- # sql (4)
- # vim (24)
- # xtdb (4)
Hi, is it possible to mix ClojureScript and JavaScript in single project and compile them to a single .js file?
The customer told us they can't write cljs and we are considering js plugins for them.
cool, found a experimental feature in shadow-cljs https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js
you have two options: use the ES Modules format or google closure module format, the advantage of using gclosure module format, is that is 100% transparent to cljs and you can (:require it like any other cljs namespace
https://github.com/penpot/penpot/blob/develop/frontend/src/app/util/text_editor_impl.js
this is an example usin ES module, we integrate with draft editor here and prefer doing it on JS, we just import it using the ["./text_editor_impl.js" :as impl]
the second format works in both shadow-cljs and regular cljs compiler, the first one (ES module format) is shadow-cljs only
https://github.com/hashql/hashql I think this is kind of clever, and something we could do in Clojure(Script) too
reading the source, it's a library that allows you to write a SQL query in your source, and at compile time will generate a hash for the client and a lookup on the server side for that hash
With macros, it should be possible to do that with anything, not just SQL queries. But I'm not sure if it's a good thing to do - both for SQL and for any other things.
If you don't find anything specifically for CLJS, you can search for a JS library and just use it via interop.
yes, i found this lib, https://github.com/exceljs/exceljs#reading-xlsx, but i don't know how to interop this in cljs
(let [workbook (Excel/Workbook.)
file (.-xlsx workbook)]
(.then (js/Promise.resolve (.readFile file "/Users/vinurs/Downloads/test.xlsx"))
#(do
(let [worksheet (. % getWorksheet 1)]
(prn worksheet)
(. worksheet eachRow (fn [row rownumber]
(prn row)))
)
))
)
like this ?
(let [workbook (Excel/Workbook.)
file (.-xlsx workbook)]
(.then (.readFile file "/Users/vinurs/Downloads/test.xlsx")
#(do
(let [worksheet (. % getWorksheet 1)]
(prn worksheet)
(prn (. worksheet getRow 1))
;; const row = worksheet.getRow(5);
;; (. worksheet eachRow (fn [row rownumber]
;; (prn row)))
))))
Ah, and wrap
Actually, that's not needed. I never use eachRow
in ()
along with the function itself..
so I don't remember its syntax.
(let [workbook (Excel/Workbook.)
file (.-xlsx workbook)]
(.then (.readFile file "/Users/vinurs/Downloads/test.xlsx")
#(do
(let [worksheet (. % getWorksheet 1)]
(prn worksheet)
(prn (. worksheet getRow 1))
(. worksheet (eachRow (fn [row rownumber]
(prn row))))
))))
No idea, I would try coming up with a JS example first for that particular spreadsheet. Then I'd try debugging.
(let [workbook (Excel/Workbook.)
file (.-xlsx workbook)]
(.then (.readFile file "/Users/vinurs/Downloads/test.xlsx")
#(do
(prn "hello ")
;; (let [worksheet (. % getWorksheet 1)]
;; ;; (prn worksheet)
;; ;; (prn (. worksheet getRow 1))
;; ;; (. worksheet (eachRow (fn [row rownumber]
;; ;; (prn row))))
;; )
)))
Evaluate this:
(let [p (js/Promise. (fn [resolve _] (js/setTimeout #(resolve "hello") 500)))]
(.then p js/console.log))
Does it output "hello"
?Your REPL setup doesn't catch print statement in async functions, that's it. Maybe asking in #shadow-cljs will help.
I'm building a react native app using shadow-cljs, expo, re-frame, reagent. Struggling a little bit to make react-navigation work properly, and I was wondering if anyone can point me to best practices on how to implement it in the most idiomatic clojure way?
I recall something called secretary ..
Thank you! Unfortunately I don't think that works with react native, but found a solution here: https://hackmd.io/@byc70E6fQy67hPMN0WM9_A/rJilnJxE8#7-Navigation