Is there a way to specify lifecycle opts when using create-app or is the expected workflow to just create the render manually at that point?
create-app is basically an example of how you compose different pieces of cljfx together, not THE way to do apps
I never use it, and after using cljfx for a long time I now also don't use context, effects and co-effects
Just a renderer and mount/unmount is enough
That makes sense. What sort of effect model do you use now? Just bind event handlers directly to the events and explicitly pass state down the tree?
I use event maps with handler functions in them:
{:fn my-handler}
The opt map event handler is usually something like #((:fn %) %)
there is usually a state though, and usually the handler updates the state. If all handlers are safe to retry, the map event handler function looks like this: #(swap! the-state (:fn %) %) , and actual handlers used in descs receive two args — state and event object, and return new state, which is semantically very nice
There might be situations though where it’s not safe to retry event handlers. In this case, I use a slightly different approach: the map event handler is #(swap! the-state ((:fn %) %)) — the handler is invoked only once, and it has to return a function that will then be used to change the app state, and that returned function is retryable
so doing side effects without any changes to the app state is done by performing the side effect in the handler, and returning identity
that’s the approach I use in reveal
wait no, I don’t use this approach in reveal 😄
Instead of {:fn my-handler} , I use {:type ::my-kw} with multi-method dispatching on :type
https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/event.clj#L31
but it’s basically the same with extra layer of indirection via keyword+multimethod. If I was making reveal from scratch again, I’d use :fn approach
Thanks! And thanks for the library. It’s been very nice to use once it clicked. And what do you use instead of context? Just explicitly pass state between components?
yes, just let the data flow from the root to the leaves