cljfx

https://github.com/cljfx/cljfx
agilecreativity 2019-04-01T03:23:46.046100Z

@vlaaad Thanks for the great project and super awesome examples and documentation.

vlaaad 2019-04-01T05:41:39.046200Z

@agilecreativity You are welcome 😊

sundbp 2019-04-01T08:10:01.051500Z

@vlaaad so my situation is this: I spin up a cljfx window, one of the things it contains is a text area to show a log. Separately to any cljfx UI I have a thread that does updates every x seconds or so. I'd like this timer fn to be able to add contents to the log shown by the UI in the text area. So I'm trying to work out how I update my state via the context from outside event handling (while also updating it within event handling). What is the appropriate pattern to follow?

sundbp 2019-04-01T08:21:03.053Z

Using normal swap! And so forth I can see my state updating as I expect, but no rendering or fx/sub's are triggered.

sundbp 2019-04-01T08:26:54.056900Z

In java style javafx it seems one would do the background/io tasks in any which way, then use Platform/runLater to update UI on the javafx thread. But that is directly mutating things etc. Trying to work out what the equivalent way to update state from background thread in cljfx is, and telling it there's new data to render.

vlaaad 2019-04-01T09:30:09.057300Z

hmm, you use create-app, right?

vlaaad 2019-04-01T09:30:19.057600Z

can you show me your swap! call?

vlaaad 2019-04-01T09:30:50.058300Z

it should be like (swap! *context fx/swap-context update :log conj new-entry) or something

sundbp 2019-04-01T09:50:11.060Z

Ah. I didn't use fx/swap-context there properly. I seem to be in business.

vlaaad 2019-04-01T10:56:21.060100Z

Glad you got it working 👍

vlaaad 2019-04-01T11:06:28.060200Z

@sundbp I want to warn you about using text areas for logs: they are not suitable for huge amounts of text, and at some point just stop displaying it. Noticed it when doing markdown example: javafx text area can't handle cljfx's readme :)

sundbp 2019-04-01T11:21:53.061300Z

It's just trailing N lines. I'll limit it to sensible number of lines.

👍 1
sundbp 2019-04-01T12:04:44.063900Z

In terms of reading context outside of the UI parts - I'm just using get-in and passing in the first cljfx.context/m key. Looks a bit ugly. Perhaps an indication I should split up my state more..

vlaaad 2019-04-01T12:06:01.064300Z

you can (and should) use fx/sub outside of UI too

vlaaad 2019-04-01T12:06:25.064800Z

:cljfx.context/m is implementation detail and you should not rely on it

sundbp 2019-04-01T12:16:01.066300Z

Ok. Somehow I thought that wouldn't work. Thanks

sundbp 2019-04-01T12:23:44.068Z

Ah. I needed to deref the context atom there to fit the sub api. Outside of the UI flows I have the context as an atom, but inside it not. That was my confusion.

vlaaad 2019-04-01T12:24:39.068200Z

ah, I see

sundbp 2019-04-01T12:38:58.069700Z

In an event handler - should I use fx/sub to pick out data from context here as well? I assume yes, just confirming :)

vlaaad 2019-04-01T12:39:10.069900Z

yes!

vlaaad 2019-04-01T12:39:27.070200Z

you have it there as a value, by the way

lilactown 2019-04-01T15:08:45.070700Z

has anyone come up with an easy way to bundle and distribute an app with Clojure + JavaFX?

lilactown 2019-04-01T15:09:30.071400Z

I'm pretty naive when it comes to distributing Java apps. I'd like to use cljfx for an internal tool but I can't depend on everyone having JDK 11 / JavaFX installed

vlaaad 2019-04-01T15:10:20.072Z

we do it at my work using python scripts to assemble jdk (stripped down with jlink) and fat jars into one package.

vlaaad 2019-04-01T15:10:29.072300Z

technology isn't here yet

vlaaad 2019-04-01T15:14:32.073100Z

and this setup isn't enough if you want autoupdates

vlaaad 2019-04-01T15:16:09.074100Z

I guess would be interesting to try to bundle app as jdk + tools.deps + deps.edn that points to "RELEASE" version of your app.

vlaaad 2019-04-01T15:18:32.074900Z

by the way, you don't need to have javafx installed, it's a regular dependency now, not a part of jdk

lilactown 2019-04-01T15:21:18.075100Z

hehe that could be clever

lilactown 2019-04-01T18:59:26.075600Z

I'm pretty new to JavaFX. any good resources for laying things out, styling things, etc.?

vlaaad 2019-04-01T19:17:55.075700Z

Ehhh don't really know. I've done cljfx going through javadoc, so mostly code documentation

vlaaad 2019-04-01T19:18:29.075800Z

https://openjfx.io/javadoc/12/index.html

vlaaad 2019-04-01T19:19:27.075900Z

They also have css reference: https://openjfx.io/javadoc/12/javafx.graphics/javafx/scene/doc-files/cssref.html

vlaaad 2019-04-01T19:22:56.076200Z

I have different layout panes in this example: https://github.com/cljfx/cljfx/blob/master/examples/e07_extra_props.clj