This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-17
Channels
- # announcements (6)
- # babashka-sci-dev (6)
- # beginners (99)
- # biff (3)
- # cider (4)
- # clerk (44)
- # clj-kondo (2)
- # clojure (65)
- # clojure-europe (57)
- # clojure-germany (5)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-spec (19)
- # clojure-uk (3)
- # clojurescript (8)
- # conjure (3)
- # cursive (21)
- # datahike (19)
- # datomic (1)
- # events (7)
- # fulcro (14)
- # graalvm (3)
- # gratitude (1)
- # guix (5)
- # honeysql (1)
- # humbleui (19)
- # hyperfiddle (39)
- # lsp (4)
- # malli (7)
- # music (1)
- # off-topic (33)
- # pathom (65)
- # re-frame (9)
- # reagent (3)
- # reitit (6)
- # releases (1)
- # sql (15)
- # tools-build (7)
- # vim (5)
- # xtdb (16)
Is there any example project that shows how to use re-frame to fetch some stuff using ajax and display it? Re-frame has loads of docs but finding it very hard to imagine how to actually use it.
You probably want to use https://github.com/day8/re-frame-http-fx. Look at the README for a usage example.
You basically define an event for your Ajax call, use the http-xhrio
effect to describe how to do the Ajax call and what events to dispatch :on-success
and :on-failure
, then define those events to handle the response.
In your :on-success
, update the db
as you want, and create subscriptions with reg-sub
to extract the data you want to render. This is no longer ajax-specific.
Thankyou!
Look into the sections of the tutorial on how to deal with side effects.[1] Alternatively, you can jump straight into the docs of re-frame-http-fx[2] [1] https://day8.github.io/re-frame/Talking-To-Servers/ [2] https://github.com/day8/re-frame-http-fx#quick-start-guide
thankyou!
Hi, I am new to the re-frame. I would like to know if is it fine to use component-local ratom in re-frame? Because when I use the following code (which adapted from TODOMVC)
clojure
(defn text-input
[]
(let [inner (r/atom "")]
(fn [] [:input
{:type "text",
:value @inner,
:on-change #(reset! inner (-> %
.-target
.-value))}])))
I always get the warning Subscribe was called outside of a reactive context
.there are no rf/subscribe calls in that function. you'll need to post code of the actual function calling rf/subscribe