This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-04
Channels
- # announcements (6)
- # babashka (7)
- # beginners (2)
- # biff (5)
- # calva (2)
- # cherry (17)
- # cider (3)
- # clj-kondo (8)
- # clojure (202)
- # clojure-brasil (8)
- # clojure-europe (20)
- # clojure-norway (23)
- # clojure-uk (4)
- # clojuredesign-podcast (5)
- # conjure (1)
- # cursive (9)
- # eastwood (22)
- # events (8)
- # fulcro (3)
- # hyperfiddle (22)
- # introduce-yourself (7)
- # lsp (67)
- # malli (1)
- # matrix (1)
- # meander (6)
- # off-topic (76)
- # pedestal (8)
- # polylith (17)
- # quil (12)
- # re-frame (2)
- # reagent (8)
- # releases (3)
- # shadow-cljs (67)
- # sql (93)
- # squint (39)
- # tools-deps (46)
- # vim (7)
what's the correct way to write this?
(e/defn Input []
(let [message "hello"
submit! (e/fn []
(js/alert message) ;; use local scope
(e/server
;; do something
))]
(dom/div
(dom/textarea
(dom/on "keydown"
(e/fn [e]
(when (= "Enter" (.-key e))
(.preventDefault e)
(submit!)))))
(ui/button
(e/fn []
(submit!))
(set! (.-innerHTML dom/node) send-icon)))))
basically trying to define an e/fn in the let statement (in order to use vars in the local scope). getting this error that I don't understand
it works if I move submit! to its own e/defn, but wondering if there's a way to do the above, similar to regular fn
I'm seeing the message missionary.Cancelled: Subscription cancelled
in my app, but everything seems to work fine. Should I be concerned, and how can I pinpoint the cause?
how can I reset the client atom without breaking the value for the server?
I am building drag and drop. unfortunately only the first time works. on subsequent drops (after the reset!
) the lead-dragging is not java.lang.long
anymore and does not transact (no error shown).
(dom/on "drop" (e/fn [_]
(e/server
(e/discard
(d/transact! !conn
[{:db/id lead-dragging
:lead/stage id}])))
(reset! !lead-dragging nil)))
initialization is:
#?(:cljs (defonce !lead-dragging (atom nil)))
(e/def lead-dragging (e/client (e/watch !lead-dragging)))
2 observations you might be unaware of
ā¢ (e/server ...)
and (reset! ...)
run concurrently
ā¢ the reset!
fires the lead-dragging
watch
good to know I actually let the lead-dragging (let [lead-dragging lead-dragging]
. this should give me the value right or do i deref?
you can first try (e/on-unmount #(reset! !lead-dragging nil))
, maybe that'll be enough to resolve the cycle
otherwise yes, deref
ing breaks the cycle since you no longer reference the watch but the atom
if the reset!
to nil
runs first it will be nil, which is why I suggested to reset on unmount
yes its in the surrounding (if-let [lead-dragging @!lead-dragging)
but then does not update when I start dragging (set the lead-dragging value)
I have an atom that I'd like to share between my standard ring HTTP routes and electric. As far as I can tell, the only way to accomplish this is to bind the atom to a dynamic var that closes over jetty ā there's no way to pass a value as an argument to electric, right? NBD, just curious
no, there's no way to pass an argument to electric. Can you share some code/snippet or more concrete information?
In electric e/*http-request*
is bound to the WS UPGRADE ring request. You could write a ring middleware to assoc your atom in the request map before electric starts.