cljfx

https://github.com/cljfx/cljfx
joelkuiper 2021-01-15T14:55:08.000700Z

Hey everyone! I'm using this awesome library to build my very first solo founded app πŸ˜›

joelkuiper 2021-01-15T14:55:15.001Z

so far it's amazing!

joelkuiper 2021-01-15T14:57:59.003700Z

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?)

vlaaad 2021-01-15T15:00:59.004300Z

Are you ready to write a lifecycle? πŸ˜„

joelkuiper 2021-01-15T15:01:20.004900Z

sure πŸ˜› I already have a few to integrate with some controlsfx components πŸ˜›

vlaaad 2021-01-15T15:02:19.006100Z

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

joelkuiper 2021-01-15T15:02:58.006600Z

ah I missed the :fx.opt/map-event-handler that seems like it might work, I'll try! Thanks!

joelkuiper 2021-01-15T15:03:33.007200Z

not entirely sure if that's the right approach yet, but if it works it works for now 😜

vlaaad 2021-01-15T15:03:47.007500Z

I use something like that in reveal

vlaaad 2021-01-15T15:05:14.009100Z

It has quite some implementation details (e.g. it has knowledge that event handler has a state atom in it)

vlaaad 2021-01-15T15:06:24.011100Z

and it uses state and ids to forward global state to the wrapped description, which you probably don’t need

joelkuiper 2021-01-15T15:06:41.011600Z

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 πŸ™‚

πŸ‘ 1
vlaaad 2021-01-15T15:07:02.011800Z

my pleasure!

joelkuiper 2021-01-15T16:29:45.011900Z

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 πŸ™‚

πŸ‘ 1