Fork me on GitHub

wondering if there is a way to get an event "behind" a re-render (ie, have it separate from the re-render batch of events) specifically i need to change my state (which will cause some nodes to delete and other to create/enter the scene) i want an event (call it ::re-focus that follows the re-render that will .requestFocus on the first node (per some css selector) in the scene graph (but this node doesn't exist until after the previous events have updated state and a re-render has occurred)


ah i guess this is basic javafx ... (fx/run-later ...) does the job


sharing code for posterity (or comment..):

(defmethod handle ::reset-focus
  [{:keys [^Scene scene-ref]}]
    (some-> scene-ref
      (.lookup ".widget") ;; first widget in scene

(defmethod handle ::switch-view
  [{:fx/keys [event]}])
  [[:state (assoc state ...)]
   ;; note: we reset-focus but only after re-render from state
   [:dispatch {::type ::reset-focus
               :scene-ref (-> event .getTarget .getScene)}])


this kind of breaks the purity of even handler but is working hmm i guess the "right way" would be to introduce a :run-later effect that invokes dispatch! within fx/run-later


@atdixon hmm, what about ext-focused-by-default? e.g. extension lifecycle that focuses the node when it's created and added to scene? I don't remember if we discussed this lifecycle before...


oh no, we didn't - that will probably come in handy for some of my use cases for this particular use case, i have a list of items in a folder when the user switches the folder, a new list of items is created and i want to find (`.lookup`) the first one and give it focus so only one (the first) of the newly created items should get focused...


i guess i could conditionally render the first one with the ext-focused-by-default , will try thanks @vlaaad !