This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-30
Channels
- # announcements (8)
- # babashka (102)
- # beginners (312)
- # calva (9)
- # clj-kondo (9)
- # cljfx (7)
- # clojure (126)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-norway (2)
- # clojure-spec (5)
- # clojure-uk (4)
- # clojurescript (13)
- # conjure (5)
- # cursive (5)
- # datalog (18)
- # datomic (8)
- # emacs (1)
- # events (3)
- # fulcro (16)
- # graphql (2)
- # gratitude (1)
- # helix (16)
- # inf-clojure (17)
- # introduce-yourself (9)
- # java (11)
- # lambdaisland (3)
- # leiningen (3)
- # lsp (8)
- # malli (3)
- # membrane (7)
- # missionary (26)
- # nextjournal (1)
- # off-topic (19)
- # pathom (3)
- # polylith (13)
- # portal (16)
- # reagent (39)
- # reitit (2)
- # releases (23)
- # remote-jobs (1)
- # shadow-cljs (40)
- # specter (3)
- # sql (12)
- # tools-deps (8)
- # tree-sitter (1)
- # vim (3)
- # web-security (6)
- # xtdb (16)
Is fx/create-app
bad/defacto deprecated? Looking around, I see comments like this that make it seem like that's the case: https://clojurians.slack.com/archives/CGHHJNENB/p1606062243154700?thread_ts=1606056375.154600&cid=CGHHJNENB
If that's true, I'm wondering:
1. Should it still be in the README as the "batteries included" way to get started with an app?
2. What then, is the preferred way to start a typical app? Just do all the boilerplate in fx/create-app minus the wrap-async stuff?
3. Following on #2, is there an example like https://github.com/cljfx/cljfx/blob/master/examples/e20_markdown_editor.clj that is updated with the "right" way to do a one-size-fits-most pure app?
Hey!
I would consider fx/create-app
bad, yes. Maybe it should be deprecated. Maybe it should get an option to not use wrap-async. In my own experience using cljfx I stopped using even more stuff — I'm not using effects/co-effects, and I'm not using contexts.
So maybe the closest to what I found useful is an example in https://github.com/cljfx/cljfx#map-events
With the exception that the example uses atom mutation in map event handler, while I made my event handlers return a function that is then used to swap the state.
I updated https://github.com/cljfx/cljfx/blob/master/examples/e09_todo_app.clj to show how I do that in Reveal (with the difference that in Reveal map-event-handler
is a multi-method)
I received very vocal reports of happy users of ctx
stuff that I don't use, so I'm not sure what's the "one-size-fits-most" would be. e09 is my opinion though 🙂
Interesting. I'd say an alternative to fx/create-app
without wrap-async would be good. I like the idea of the "full enchilada" pure app on the surface at least, so I'm just cranking out this boilerplate for my case, which seems to cover it:
(def renderer
(fx/create-renderer
:middleware (comp
fx/wrap-context-desc
(fx/wrap-map-desc (fn [_] {:fx/type root})))
:opts {:fx.opt/map-event-handler
(-> handle-event
(fx/wrap-co-effects {:fx/context (fx/make-deref-co-effect *context)})
(fx/wrap-effects {:context (fx/make-reset-effect *context)
:dispatch fx/dispatch-effect
:read-dir read-dir}))
:fx.opt/type->lifecycle #(or (fx/keyword->lifecycle %)
(fx/fn->lifecycle-with-context %))}))