Hey everyone! I'm using this awesome library to build my very first solo founded app π
so far it's amazing!
there's one tricky bit that I'm kinda stuck at. I have a grid of thumbnails that I want to display, generating those thumbnails is done in a separate thread pool and then cached to a file, which means that it might not yet exist when I'm displaying the thumbnail. Right now I'm triggering an event that requests the thumbnails to be generated on application initialization, but I'd rather prefer to dispatch when the thumb enters the scene (so it doesn't end up requesting all of them on app boot). Is there a hacky way to dispatch an event when a node enters the scene (or I guess even hackier, dispatch an event from a subscription?)
Are you ready to write a lifecycle? π
sure π I already have a few to integrate with some controlsfx components π
Lifecycle receives opts
on create/advance/delete, opts
has :fx.opt/map-event-handler
, you can use it to dispatch events when cljfx component is created
ah I missed the :fx.opt/map-event-handler
that seems like it might work, I'll try! Thanks!
not entirely sure if that's the right approach yet, but if it works it works for now π
I use something like that in reveal
https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/fx.clj#L21
It has quite some implementation details (e.g. it has knowledge that event handler has a state atom in it)
and it uses state and ids to forward global state to the wrapped description, which you probably donβt need
cool! I'll investigate that path for now then! I must say that I truly enjoy this library. Combined with datascript/datahike for persistence it makes cross platform desktop app development far less painful than I initially imagined. It's still a lot of work though, but from the comfort of Clojure it isn't so bad π
my pleasure!
worked fine! I now dispatch the request-thumbnails event on :start that does the background processing and then emits another event that sets some state which the thumbnails subscribe to. Carved out some of the impl details as you suggested π