MutableObservableList

A mutable list, which can be observed by ListChangeListeners and InvalidationListeners.

Note, the collection names in Glok use Kotlin's naming convention. So an ObservableList is not mutable, whereas MutableObservableList is.

Comparing Glok with JavaFX :

  • Glok : ObservableList <-> JavaFX : ReadOnlyObservableList

  • Glok : MutableObservableList <-> JavaFX : ObservableList

The easiest way to create a MutableObservableList is to wrap an existing (non-observable) list using asMutableObservableList :

val myObservableList = myMutableList.asObservableList()

Afterwards, you should never modify myMutableList directly, as those changes will not be heard by any ListChangeListeners, or InvalidationListeners.

See ObservableList for a class diagram.

Functions

Link copied to clipboard
open fun addAll(vararg items: E): Boolean
Link copied to clipboard
Link copied to clipboard
abstract fun removeBetween(indices: IntRange)
Link copied to clipboard

Sync this mutable list with other. Returns a ListChangeListener for this list. To stop syncing, remove the listener using MutableObservableList.removeListener. As Glok uses weak references for listeners, you must keep a reference to this listener, otherwise the garbage collector will end the sync.