Fork me on GitHub
#cljfx
<
2022-03-30
>
acim123:03:34

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&amp;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?

vlaaad18:04:18

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.

👀 1
vlaaad18:04:05

So maybe the closest to what I found useful is an example in https://github.com/cljfx/cljfx#map-events

vlaaad18:04:18

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.

vlaaad18:04:59

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)

vlaaad18:04:03

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 🙂

acim117:04:20

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 %))}))

👍 1