This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-11
Channels
- # announcements (3)
- # babashka (62)
- # beginners (58)
- # calva (40)
- # cider (3)
- # clj-kondo (75)
- # cljdoc (14)
- # clojars (8)
- # clojure (110)
- # clojure-australia (6)
- # clojure-europe (38)
- # clojure-hungary (1)
- # clojure-india (4)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-spec (4)
- # clojure-uk (3)
- # clojurescript (45)
- # conjure (4)
- # cursive (35)
- # data-science (1)
- # datomic (11)
- # events (2)
- # exercism (4)
- # figwheel-main (4)
- # fulcro (103)
- # graphql (16)
- # helix (1)
- # holy-lambda (16)
- # honeysql (1)
- # introduce-yourself (3)
- # jobs (1)
- # keyboards (2)
- # lsp (4)
- # malli (11)
- # membrane-term (3)
- # mount (2)
- # nextjournal (2)
- # off-topic (53)
- # pathom (30)
- # pedestal (2)
- # portal (22)
- # rdf (1)
- # re-frame (7)
- # reagent (3)
- # reitit (5)
- # remote-jobs (6)
- # shadow-cljs (20)
- # sql (8)
- # tools-build (10)
- # vim (4)
- # xtdb (12)
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! 🙂 https://stackoverflow.com/questions/58700950/persistentvector-cannot-be-cast-to-class-iatom 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 https://www.reddit.com/r/Clojure/comments/hua7p2/nonexistent_clojurelang_in_clojurescript/fym5kyb/, 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 https://github.com/kardan/taxa/blob/main/src/main/com/kardans/taxa.cljc#L107
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.")
Reagent uses it:
{:pre [(satisfies? IAtom a)
(ifn? f)]}
Prismatic schema uses it:
(defn- atom? [x]
(satisfies? IAtom x))
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 https://github.com/emotion-js/emotion/tree/main/packages/react/isolated-hoist-non-react-statics-do-not-use-this-in-your-code
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)
java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
...
shadow.build.cache/write-file (cache.clj:24)
shadow.build.cache/write-file (cache.clj:24)
shadow.build.closure/convert-sources-simple/fn--12746/fn--12748 (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
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 😛
thankyou
maybe reiserfs, if I can overcome scruples
I'm still wrestling to understand the purpose of that file; it is intriguingly named
I think materialui is a common library, so I'm guessing alot of people will trip over this
yeah I didi not understand the length
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 🧵)
(ns reframe-example.views
(:require
[re-frame.core :as re-frame]
[reframe-example.events :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)])]
[:div
[:input.typing {:value @input-value
:type "text"
:on-change input-changed}]
[:div @input-value]]))
The event:
(re-frame/reg-event-db
::update-input-value
(fn [db [_ val]]
(assoc db :input-value val)))
The subscription:
(re-frame/reg-sub
::input-value
(fn [db]
(:input-value db)))
Your code is perfectly fine. There's an FAQ entry about that problem: https://day8.github.io/re-frame/FAQs/laggy-input/
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 🙏
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})'
#'cljs.user/destr
[nil nil {{:a 1} nil}]
vs.
λ 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})'
#'cljs.user/destr
(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?(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 http://ask.clojure.org. slack tends to get lost
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
@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
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