Fork me on GitHub

Hello, all! I am trying to write a clojure.spec to ensure that a function argument is actually an atom, as opposed to one that’s already dereferenced. I ran into this post, which was great (thanks, 2016 version of @alexmiller! 🙂 So this works in Clojure REPL:

(instance? clojure.lang.IAtom (atom {}))
=> true
What is the way to do this in ClojureScript? In a CLJS REPL, I get clojure.lang.IAtom isn’t found. After reading, I think maybe this should work, but it returns false?
(instance? IWatchable (atom {}))
=> false
Any advice? Thanks in advance!


Think you got a response but for reference since you asked for a Clojure and a Cljs solution I did


This is awesome, @U051F5T93 — thank you!


(type (atom {})) is cljs.core/Atom. So i tried (instance? cljs.core/Atom (atom {})). But i don’t know if that’s a robust solution but seems straightfoward


Thank you, @U11BV7MTK! I just learned about satisfies? too.


In cljs/core.cljs, there's this thing that built-in atoms use:

(defprotocol IAtom
  "Marker protocol indicating an atom.")


This is terrific, thank you! I never thought about satisfies? — very cool.


Reagent uses it:

{:pre [(satisfies? IAtom a)
         (ifn? f)]}
Prismatic schema uses it:
(defn- atom? [x]        
  (satisfies? IAtom x))

Ben Hammond08:11:56

Trying to run material-ui 5.1.0 / emotion-js / React with shadow-cljs I get a file-name too long error from @emotion/react hoist file I am running Ubuntu 20.04.3

FileNotFoundException: .shadow-cljs/builds/elephantchess/dev/shadow-js/module$node_modules$$emotion$react$isolated_hoist_non_react_statics_do_not_use_this_in_your_code$dist$emotion_react_isolated_hoist_non_react_statics_do_not_use_this_in_your_code_browser_cjs.js (File name too long) (
... (cache.clj:24) (cache.clj:24) (closure.clj:2113)
Has anyone found a workaround for this ? (I'm just trying to upgrade to mui v5; I've only had this working on material-ui v4) I'm not aware that I care about hoisting non-react statics, think I would be happy if I could nudge shadow-cljs into ignoring this fille... Can I do that? Would I regret it?


hmm this has come up before. I guess I'll need to add something to shorten the filenames somehow


or can you increase the file name max length on ubuntu somehow?

Ben Hammond09:11:42

I've got a feeling it is built in to the ext4 filesystem maybe I can partition with a new fs


well I can just shorten the name after a certain length. didn't expect anyone to use such long filenames ... but I guess everything exists on npm 😛

Ben Hammond09:11:29

that would be lovely if you would do that

❤️ 1
🙏 1

should be fixed in 2.16.3

👏 1
Ben Hammond09:11:44

maybe reiserfs, if I can overcome scruples

Ben Hammond09:11:30

I'm still wrestling to understand the purpose of that file; it is intriguingly named


according to the internet the max file name length is 255 bytes

Ben Hammond09:11:03

I think materialui is a common library, so I'm guessing alot of people will trip over this


but the filename is only 193 bytes?


only appears to be a linux issue. windows and mac seem to be fine

Ben Hammond09:11:37

yeah I didi not understand the length

Nathan K10:11:05

Hi all. Any thoughts on this re-frame code? It’s a basic input field, I’m trying to keep track of its value, and I’m rendering its value to a separate div. As written, it has some kind of performance problem, I’m not 100% sure why. (code in thread 🧵)

Nathan K10:11:14

(ns reframe-example.views
   [re-frame.core :as re-frame]
   [ :as events]
   [reframe-example.subs :as subs]))

(defn main-view []
  (let [input-value (re-frame/subscribe [::subs/input-value])
        input-changed #(re-frame/dispatch [::events/update-input-value
                                           (-> % .-target .-value)])]
     [:input.typing {:value @input-value
                     :type "text"
                     :on-change input-changed}]
     [:div @input-value]]))

Nathan K10:11:22

The event:

 (fn [db [_ val]]
   (assoc db :input-value val)))
The subscription:
 (fn [db]
   (:input-value db)))


Your code is perfectly fine. There's an FAQ entry about that problem:

Nathan K11:11:57

Interesting, I wonder why elm doesn’t have this issue with seemingly equivalent code. Maybe some difference in the event loop. Thank you for your help 🙏

👍 1

Looks like ClojureScript 1.10.879 and 1.10.891 behave differently when passing a map to a function that accepts keyword arguments:

λ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.879"}}}' -M -m cljs.main --repl-env node -e '(defn destr [& {:keys [a b] :as opts}] [a b opts]) (destr {:a 1})'
[nil nil {{:a 1} nil}]
λ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.891"}}}' -M -m cljs.main --repl-env node -e '(defn destr [& {:keys [a b] :as opts}] [a b opts]) (destr {:a 1})'
(node:62287) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead. (Triggered by calling emit on process.)
(Use `node --trace-deprecation ...` to show where the warning was created)
Execution error (ExceptionInfo) at cljs.repl/evaluate-form (repl.cljc:577).
Execution error (Error) at (<cljs repl>:1).
No value supplied for key: {:a 1}
I understand why this throws an exception, but it took me by surprise since there's no mention of this in the change log. Could maybe add a note?


(The node deprecation warning is unrelated, dunno what that's about.)


(Also, it seems that there's 1.10.893 in Maven Central, but there are no release notes for it.)


looks like a bug to me. best report it to jira or slack tends to get lost


All right, will make an Ask post about it.


hmm maybe its not actually a bug. CLJ behaves the same


Right, CLJ (prior to 1.11.*) behaves the same as 891. Our codebase had a couple of bad calls like that where things worked regardless with 879, but with 891 they throw.


@flowthing it's because a map bug was fixed, which is in the change log


Hmm, not sure which change log entry you're referring to, but all right.


@flowthing sorry, you were right, this one was missing added


was not intentionally left out - why I thought it was there - thanks for pointing it out


If I wanted to create a website and wanted to make sure google saw it properly, should I use fulcro (which I know does awesome ssr) or can I use re-frame like I want to with some library?


What kind of site are you creating? E.g. blog, app et al


it's going to be a spa that's really interactive


Right. I think what I was going to suggest is that Apps don’t have the same SEO requirements as a blog or marketing site. Thus, depending on what you are building, I would say you may not want to go the SPA route. You can still use CLJS if you like.


Either way, this problem is unrelated to CLJS. So, the same tricks you would use in JS and React land would apply here and there will be more content written about the subject in general.


if you know fulcro well then yes, it has awesome ssr and I would highly recommend fulcro. But if you're not familiar with it, then there's a huge risk because it takes time to master fulcro