-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make behavior more similar to cljs freactive: Reactively bind children nodes #6
Comments
So fx-clj does not support child node binding yet, but it could be done. I think it would be easier to do now that the cljs freactive is more structured. I won't have time to work on this in the foreseeable future, but a PR would be accepted. If it is something that you'd want to tackle, I can explain how to approach it. |
I think, having given it a bit more time, I would like to do a PR for this. Any explanations or insights you have would very much be appreciated. Another thing I'd like to do is to have a One random question: will a view need to be re-created each time it is reactively invalidated? E.g.:
Will a new
|
This is what I've currently hacked together to get some semblance of immutability with an observable collection. Not the prettiest, but here it is: (defrecord FXObservableAtom
[^clojure.lang.IAtom immutable
^com.sun.javafx.collections.ObservableListWrapper observable])
(defn fx-observable-atom [v]
(FXObservableAtom. (atom v) (->observable v)))
(defnt oswap!*
[List]
([x f args]
(condp = f
conj (fx/run! (.addAll x args))
assoc (fx/run!
(doseq [i v (into {} args)]
(.set x i v)))
update (let [i (first args)
update-f (second args)]
(fx/run! (.set x i (update-f (.get x i)))))
(throw+ (Err. :illegal-operation "Not an allowed operation for oswap:" f))))
[FXObservableAtom]
([x f args]
(oswap!* (:observable x) f args)
(apply swap! (:immutable x) f args)))
(defn oswap! [x f & args]
(oswap!* x f args)) Note that |
Cool. So first of all have you taken a look at how fx-clj sets the default property on nodes: https://github.com/aaronc/fx-clj/blob/master/src/fx_clj/core/pset.clj? Also, make sure you understand what JavaFX is doing with this attribute: https://docs.oracle.com/javase/8/javafx/api/javafx/beans/DefaultProperty.html. My recommended approach to dealing with collection stuff is the One thing to keep in mind is that in freactive for the DOM, there are "virtual elements" whereas in fx-clj, I am just using Node's directly. I think it would be a major rewrite to do it differently. Using "virtual elements" may provide a few benefits, but I don't think it's really worth it for the work involved. Probably just "projecting" a cursor to some items onto nodes will do a lot. Does that help? |
I took a look at Thanks for your help! |
I was trying to do the following just as an experiment within a function:
The exception I receive is:
Besides the differences in properties and tag names, something like this should work in the ClojureScript equivalent (e.g., with divs and buttons and the like). What needs to be done to make it work as in ClojureScript, i.e., by reactively binding children nodes to parent nodes as opposed to just properties to nodes?
The text was updated successfully, but these errors were encountered: