carlw
01/29/2018, 2:41 PMRuckus
01/29/2018, 3:41 PMval dirty = InvalidationListener { ... }
init {
source.xScaleProperty.addListener(WeakInvalidationListener(dirty))
source.yScaleProperty.addListener(WeakInvalidationListener(dirty))
}
vs
val dirty = InvalidationListener { ... }
init {
val weak = WeakInvalidationListener(dirty)
source.xScaleProperty.addListener(weak
source.yScaleProperty.addListener(weak)
}
carlw
01/29/2018, 9:55 PMRuckus
01/29/2018, 9:57 PMdirty
is an InvalidationListener
stored as a member so it won't get reclaimed. My question was if there is a downside to just using a single weak reference to the listener. I'll update my example to make it clearer.
Updatedcarlw
01/29/2018, 10:19 PMcarlw
01/29/2018, 10:19 PMhestad
01/30/2018, 9:55 AMchildren.bind(myController.list.sorted(sortOuter())) { element ->
from my example on friday. sorted() returns a SortedList, which will only survive in the scope of the bind function. As the bind function doesn't keep a reference of what it binds to, the garbage collector comes cleaning it up.