Short version:

Is there any way to get JavaFX (8.0) to tell Clojure that a Property is no 
longer available, such that I may (remove-watch) a watch on a ref/atom 
which notifies that Property of ref/atom changes?


Long version:

My domain/application data is a nested Clojure hash-map that lives in a 
ref/atom, and I wish to tie specific sub-elements of the map to one or more 
UI elements. Call this big map global-var. I do not wish to maintain my 
domain data as a bunch of JFX Properties, since this was the whole point of 
using Clojure and its data structures and functions, so I'm not considering 
using JFX Bind...functions to tie UI elements to my domain data. I'm only 
dealing with JFX Properties as they exist naturally inside JFX objects and 
trying not to create more.

To implement the "observable" pattern, I have a ChangeListener on each JFX 
Property (such as the textProperty of a TableCell inside a TableView) which 
updates the entire global-var.

To notify the various properties of changes to global-var, I also do 
add-watch on the global-var for each property receiving change 
notification, with some special cases to prevent infinite looping.

The problem is *un*registering watches. In the case of TableView, the JFX 
engine creates new cells all the time -- at least twice just for showing 
the window, and evidently at least twice every time I update the global-var.

Specifically, following the various examples I've found, when the column's 
TableCell's updateItem method is called, I create a new graphic element for 
that cell. This allows me a different cell type for each row within a 
column, rather than the default where each cell in a column is the same. So 
every time the cell is updated, a new (proxy of) TableCell is created, and 
a new watch is added to the global-var.

I don't mind constantly creating new objects since the JVM is supposed to 
be good at garbage collection, but I'm annoyed that with each new UI 
element I'm adding an additional watch to the global-var, with no mechanism 
to know when to do remove-watch. Even with a single property, the number of 
watches increments (without bound) each time the data changes, because of 
how TableView works.

There are some special cases possible based on the Stage's onCloseRequest, 
but these don't apply in the case of TableView.

So the question is, Is there a way of finding when a JFX Property is no 
longer accessible, either through some type of destructor, event, callback, 
or other notification, such that I may remove-watch?

Or must I find a way of somehow caching the Property or cell, etc., so I 
can maintain the same watch on it?


Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to