cljfx

Jonathan Bennett 2023-12-16T09:57:54.835829Z

Ok, I'm trying to figure out how to use to get useful error messages, but I cannot figure out what how I'm supposed to do it if I'm also using contexts

Jonathan Bennett 2023-12-16T09:59:48.297169Z

Here's my renderer and my main fn, which is where I think the documentation says I'm supposed to make the change:

(def renderer
  (fx/create-renderer
    :middleware (comp
                  fx/wrap-context-desc
                  (fx/wrap-map-desc (fn [_] {:fx/type views/root})))
    :error-handler (bound-fn [^Throwable ex]
                     (.printStackTrace ^Throwable ex *err*))
    :opts {:fx.opt/map-event-handler event-handler
           :fx.opt/type->lifecycle #(or (fx/keyword->lifecycle %)
                                        (fx/fn->lifecycle-with-context %))
           }))

(defn -main
  []
  (Platform/setImplicitExit true)
  (fx/mount-renderer *state renderer))
Where do I add the relevant :fx.opt/type->lifecycle ? It's an or, do I just drop it in there?

vlaaad 2023-12-16T17:58:43.344069Z

You use it to wrap your own lifecycle

vlaaad 2023-12-16T17:59:24.022769Z

There is cljfx.dev/wrap-type->lifecycle

vlaaad 2023-12-16T18:00:05.050959Z

Use that to wrap your lifecycle

vlaaad 2023-12-16T18:01:16.648789Z

So it looks like this: ... :fx.opt/type->lifecycle (cljfx.dev/wrap-type->lifecycle #(or ...)) ...

Jonathan Bennett 2023-12-17T03:04:47.646009Z

Ok, so when I try that I get the following error. And removing that wrap removes the error:

clojure.lang.ExceptionInfo: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null

Jonathan Bennett 2023-12-17T03:05:52.760519Z

I'm currently not using the devMode? flag, I'm just hard-coding it in first to test it. The relevant opt looks like this:

:opts {:fx.opt/map-event-handler event-handler
           :fx.opt/type->lifecycle (cljfx.dev/wrap-type->lifecycle
                                    #(or (fx/keyword->lifecycle %)
                                         (fx/fn->lifecycle-with-context %)))}))

vlaaad 2023-12-17T07:52:36.725289Z

Hmm

vlaaad 2023-12-17T07:53:04.164179Z

What's the stack trace?