WeakListChangeListener

Using weak listeners can help prevent memory leaks.

A Weak Listener is a wrapper around an inner listener. The wrapper contains a weak reference to the inner

The wrapper should be added to the list of listeners (via ObservableList.addChangeListener`)

You have to keep a reference to inner, otherwise it will be garbage collected, and the listener will stop working.

When your class (which holds the returned reference to inner) is garbage collected, there will be no strong references to inner, so it too will be garbage collected, and the listener will stop.

To remove a weak listener, pass inner or this to ObservableList.removeChangeListener. (ObservableList.removeChangeListener has special code which removes the wrapper (this), even when the inner is passed to it).

Constructors

Link copied to clipboard
constructor(wraps: ListChangeListener<E>)

Functions

Link copied to clipboard
Link copied to clipboard
open override fun changed(list: ObservableList<@UnsafeVariance E>, change: ListChange<@UnsafeVariance E>)