Can someone explain like I'm five what this code is doing?
(fx/mount-renderer
*state
(fx/create-renderer
:middleware (fx/wrap-map-desc assoc :fx/type root)
:opts {:fx.opt/map-event-handler #(swap! *state (map-event-handler %))}))
from the cljfx example: https://github.com/cljfx/cljfx/blob/master/examples/e09_todo_app.clj
Here's my attempt:
• From the docs, it seems like fx/mount-renderer is adding a watch to the *state atom and calling render on the UI map (aka description?). Straightforward enough.
• fx/create-renderer creates a function that causes the UI to be rendered. OK.
• :opts is providing an event handler for UI callbacks (eg {:event/type press})
But I don't really understand fx/wrap-map-desc. It appears that it 1) provides the function to call to get the UI map/description (the resulting map seems to need {:fx/type root} in it), and 2) allows me to modify the state that's passed into that second arg (assoc, above).
Why would I want to modify the state here?