Fork me on GitHub

@alex.sheluchin walkable is an modern alternative to toucan and does support clojurescript


Thanks, checking it out now. Is Toucan no longer considered "modern"? Just curious.


Frankly Toucan is an Orm, with N+1 problem and inflexibility. It hides database in a global state, so you cant use more than one db throughout your codebase


Js interop question: Assuming you're using shadow-cljs, how do you write an equivalent cljs code?

const db = require('db')

const client = new db.Client({
    secret: process.env.DB_SERVER_SECRET


probably something like

(ns core.example
 (:require [db :refer [Client]]))

(def client (Client. #js {:secret (aget process "env" "DB_SERVER_SECRET")}))

Michaël Salihi10:03:16

(ns mynamespace
  (:require ["db" :refer [Client]]))

(def client (Client. #js {:secret (.. js/process -env -DB_SERVER_SECRET)}))

👍 8
Michaël Salihi10:03:51

Arf you were faster @UFJD2TV46 🙂

parrot 4

I think that you can now require npm libraries without quotation marks. Ain’t that right? (:require ["db" :refer [Client]]) vs (:require [db :refer [Client]])

Michaël Salihi10:03:23

Yes I think you are right, Clojurescript manages this for several versions however the developer of Shadow-CLJS indicates that the quotes are preferable in order to differentiate the CLJS vs NPM JS libraries. And I'm agree. You confirm @thheller?


yes, absolutely ALWAYS use strings for npm requires

👍 4
👌 4
Michaël Salihi10:03:48

Thx for the confirmation.


FWIW I think strings should be used since it makes it clear for the user that this is JS code and not CLJS. it also helps the compiler since it doesn't have to treat every folder in node_modules as a potential namespace. also no ambiguity when using package names that CLJS would encode like some-dash or @material-ui/foo etc

👍 8
Michaël Salihi10:03:23

Yes I think you are right, Clojurescript manages this for several versions however the developer of Shadow-CLJS indicates that the quotes are preferable in order to differentiate the CLJS vs NPM JS libraries. And I'm agree. You confirm @thheller?


Any clojurescript expert interested in helping out with js interop in borkdude/sci?

Mark Bailey15:03:05

Very small CLJS question for y'all

Mark Bailey15:03:19

I have

(defonce booking (atom {:text "Hello!"
                        :status false}))

(defn booking-swap
  (println "updating status")
  (println (swap! booking update-in [:status] #(not %)))
  (println (get-in booking [:status])))


You can also pass “not” just by itself, no need to wrap it in a function

Mark Bailey15:03:19

this is run when I click the booking button. Only problems is (println) on the swap! call returns the correct value. Next (println) for the get-in returns nil


Missing a deref? (i.e. (println (get-in @booking [:status])))


@mbbailey96 booking is an atom, so the last println should be

(println (get-in @booking [:status]))

Mark Bailey15:03:06

Thank you! Atom syntax has been unclear to me so far. I was wondering if i needed to deref.


Say @borkdude, I am getting a warning compiling my sci using project under shadow-cljs and I am wondering if it is something I am doing wrong, something I should open an issue about, or something I should just ignore because everything seems to actually work. Here is the output, in case you can help me choose a direction:

shadow-cljs - config: /Users/james.elliott/git/bytefield-svg/shadow-cljs.edn  cli version: 2.8.90  node: v12.14.1
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - starting via "clojure"
[:lib] Compiling ...
[:lib] Build completed. (80 files, 3 compiled, 1 warnings, 2.43s)

------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: sci/impl/multimethods.cljc:96:3
  93 | 
  94 | (defn multi-fn-add-method-impl
  95 |   [multifn dispatch-val f]
  96 |   (#?(:clj .addMethod
 Use of undeclared Var sci.impl.multimethods/clojure
  97 |       :cljs -add-method) ^clojure.lang.MultiFn multifn dispatch-val f))
  98 | 
  99 | (defn defmethod
 100 |   "Creates and installs a new method of multimethod associated with dispatch-value. "


I might have already fixed that on master. Could you check?


I guess you can try building with shadow-cljs + sci as a git dep.


Ah, interesting, this is my first deps.edn project, which should make that much easier to try! I will do a little research and report back. Thanks!


you can also join #babashka for sci questions


maybe shadow-cljs has difficulty processing the type hint ^clojure.lang.MultiFn?


I don't know if shadow-cljs uses the normal CLJS compiler, that has no problem with it


it does use the normal CLJS compiler but has a bit stricter validation on some things ...


Ok, I will move future questions over there. I can report that I see the exact same error using master with git SHA f2424029275dac218396d9d532a8bb757aaac1db though.


but we can re-org the reader conditionals a bit if it's a problem


I think the type hint should be moved inside the :clj branch maybe


I am unfortunately a complete ClojureScript newbie, so an issue is all I can offer.


so just make two more elaborate branches for both :clj and :cljs


that's fine too. can you make a repro?


I’ll give it a shot. Thanks again!


Well, if checking out my project counts as a repro, we have one today.


(with a walk-through of the build)


this proposal seems pretty amazing:

✔️ 4

If this happens, they should allow them to be sent to web workers without serializing


@deep-symmetry Can you just try again with f3f3619ec8d217b08a299604adee21c57dc50181?


Just in time before my meeting! It compiles cleanly. 🎉


ok, no need to make an issue then. 🙂

👍 4