This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-03
Channels
- # announcements (2)
- # asami (1)
- # babashka (32)
- # beginners (125)
- # calva (4)
- # cider (1)
- # clj-kondo (16)
- # clj-together (1)
- # cljs-dev (15)
- # clojure (30)
- # clojure-australia (3)
- # clojure-europe (41)
- # clojure-italy (1)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (68)
- # clojure-uk (28)
- # clojurescript (36)
- # conjure (2)
- # cryogen (1)
- # cursive (2)
- # data-science (2)
- # datascript (2)
- # datomic (70)
- # events (2)
- # fulcro (11)
- # graalvm (1)
- # jobs (4)
- # kaocha (4)
- # leiningen (4)
- # malli (52)
- # meander (21)
- # off-topic (11)
- # pathom (7)
- # pedestal (17)
- # reagent (23)
- # reitit (5)
- # remote-jobs (5)
- # reveal (7)
- # shadow-cljs (24)
- # spacemacs (36)
- # sql (21)
- # vim (18)
- # xtdb (7)
How do I use debounce in combination with input on-change? I tried using goog.functions.debounce and goog.async Debouncer but I'm constantly running into "This synthetic event is reused for performance reasons....If you must keep the original synthetic event around, use event.persist()". Then I try adding (.persist e) but it doesn't help. I must be missing something but I've been stuck on this for hours. Any help is appreciated! Edit: Think I got it finally, this combination worked in case anyone is struggling with the same issue:
;;
(:import [goog.async Debouncer])
(defn debounce [f interval]
(let [dbnc (Debouncer. f interval)]
(fn [& args] (.apply (.-fire dbnc) dbnc (to-array args)))))
(defn input-on-change [e]
(.log js/console (.. e -target -value)))
(def input-on-change-debounced
(debounce input-on-change 1000))
..........
:on-change (fn [e]
(.persist e)
(input-on-change-debounced e))
Hi, I have a re-frame interceptor set up after every event to check the modified db against my spec (following https://github.com/oskarth/re-frame-docs/blob/master/re-frame-one-doc.md#3-checking-db-integrity using prismatic/schema
). However, the schema validator fails when my db is first being initialized since it's simply an empty map at that point. As a result I get errors like schema problem: {:logged-in-user {:uid missing-required-key}}
because the user hasn't logged in yet.
I know I could set optional keys but that seems a bit counter-productive to me. Does anyone have a better solution?
Do you check your schema in an :after
or a :before
interceptor?
You should use :after
and have the very first event in your app set up the correct initial DB state.
Hi ! Is there a way of of defining a macro that will change the current namespace in clojurescript at the repl?
(defmacro def-in-core []
`(do
(in-ns (quote cljs.core))
(def a 42)))
This currently expands to (cljs.core/in-ns 'cljs.core) which doesn't exist.
What I'm trying to acomplish is a macro that can create a def in a different ns.this doesn't work in CLJS. in-ns
is a special form that won't be handled when emitted like that
yeah I imagined, hmmm
@U05224H0W When using that macro (assuming in-ns
is quoted) as
(def x 1)
(def-in-core)
(def y 2)
how is that not equivalent to
(def x 1)
(do
(in-ns 'cljs.core)
(def a 42))
(def y 2)
?
After all, macros expansion is done before CLJS compilation.> repl specials happen before macro expansion and not after
Oh. Huh. So in-ns
doesn't exist outside of REPL at all in CLJS?
Use of undeclared Var clj-playground.core/in-ns
Thanks! Do you know of any comprehensive resource that would describe all the steps/stages and what specials available at which step/stage?
dont know about default CLJS anymore. the shadow-cljs specials are here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/repl.clj#L401-L425
this is mostly because things like require
may require async IO for loading files and stuff
its definitely there and pretty sure it looks the same. just don't know where it is anymore 😉
Maybe I can use (goog/define "cljs.core.odd_QMARK_" (fn [n] 5))
or something like that if I want to lets say replace odd? in cljs.core :thinking_face:
I'm looking at the goog-define src
@U0739PUFQ no. you can use (set! cljs.core/odd? (fn [n] 5))
but not goog-define
. be very careful doing this though.
oh that is better
I'm creating a instrument macro, and want to be able to do (trace-var cljs.core/map) so it grabs the source using source-fn, instrument it, and then replace the original with the instrumented version
it is working fine in clojure, but was having trouble in cljs
oh yeah I was going to take a look at instrument but forgot
thanks @U05224H0W!
so apparently ClojureScript depends on a few parts of the com.google.javascript.jscomp
API (eg. AnonymousFunctionNamingPolicy
) that have been removed recently. in 20200920 for that enum specifically, not sure otherwise. is there a nightly or prerelease version of CLJS out there that works with the latest Closure compiler?