This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-16
Channels
- # ai (5)
- # announcements (47)
- # aws (11)
- # babashka (20)
- # beginners (85)
- # biff (1)
- # calva (72)
- # cider (9)
- # clj-kondo (37)
- # cljfx (9)
- # cljs-dev (1)
- # clojars (2)
- # clojure (61)
- # clojure-berlin (2)
- # clojure-europe (189)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-uk (2)
- # clojurescript (51)
- # conjure (3)
- # cursive (4)
- # data-science (6)
- # datomic (6)
- # events (5)
- # fulcro (16)
- # gratitude (9)
- # holy-lambda (9)
- # introduce-yourself (6)
- # lsp (13)
- # malli (8)
- # membrane (2)
- # off-topic (47)
- # pedestal (11)
- # re-frame (15)
- # reitit (1)
- # releases (2)
- # rewrite-clj (6)
- # rum (4)
- # shadow-cljs (2)
- # tools-deps (3)
- # xtdb (25)
- # yada (13)
The below looks like a form-2 component to me.
This example is taken from the tutorial:
(defn timer-component []
(let [seconds-elapsed (reagent/atom 0)] ;; setup, and local state
(fn [] ;; inner, render function is returned
(js/setTimeout #(swap! seconds-elapsed inc) 1000)
[:div "Seconds Elapsed: " @seconds-elapsed])))
Here timer-component is the outer function, and it returns an inner, anonymous render function which closes over the initialised, local state seconds-elapsed.
As before, the job of the render function is to turn data into HTML. That's the backbone. Its just that Form-2 allows your renderer to close over some state created and initialised by the outer.
I'm kind of a noob so I can't really explain it in my own words, but this is from the documentation
@USDPTD3FY, Thanks for the response, What happens when we not define function? Does that give same result ?
Same result. If you don't need form-2 style local state, there's no reason to define your react component with the (fn [] )
Hi there, I started a thread in #clojurescript and it was suggested that it be linked here since it concerns re-frame. https://clojurians.slack.com/archives/C03S1L9DN/p1663169861173409
In short, you use fx handlers for async (promise) api interaction then chain together a series of event handlers that use that fx handler.
Original HTTP FX - https://github.com/day8/re-frame-http-fx
Alpha HTTP fx exploring a state machine based approach - https://github.com/day8/re-frame-http-fx-alpha
Fetch fx w/ promise but no state machine experiments - https://github.com/superstructor/re-frame-fetch-fx
Thanks, @U0G75S29H!