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.

Properties

Link copied to clipboard
abstract override val size: Int

Functions

Link copied to clipboard
abstract override fun add(element: E): Boolean
abstract fun add(index: Int, element: E)
Link copied to clipboard
abstract override fun addAll(elements: Collection<E>): Boolean
abstract fun addAll(index: Int, elements: Collection<E>): Boolean
open fun addAll(vararg items: E): Boolean
Link copied to clipboard
open fun addChangeListener(lambda: (list: ObservableList<E>, change: ListChange<E>) -> Unit): ListChangeListener<E>
abstract fun addChangeListener(listener: ListChangeListener<E>)
Link copied to clipboard
abstract fun addListener(listener: InvalidationListener)
Link copied to clipboard
open fun addWeakChangeListener(lambda: (list: ObservableList<E>, change: ListChange<E>) -> Unit): ListChangeListener<E>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Wraps a regular list, creating a MutableObservableList.

Link copied to clipboard
Link copied to clipboard
abstract override fun clear()
Link copied to clipboard
abstract operator override fun contains(element: E): Boolean
Link copied to clipboard
abstract override fun containsAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract operator fun get(index: Int): E
Link copied to clipboard
abstract fun indexOf(element: E): Int
Link copied to clipboard
abstract override fun isEmpty(): Boolean
Link copied to clipboard
abstract operator override fun iterator(): Iterator<E>
Link copied to clipboard
abstract fun lastIndexOf(element: E): Int
Link copied to clipboard
abstract override fun listIterator(): MutableListIterator<E>
abstract override fun listIterator(index: Int): MutableListIterator<E>
Link copied to clipboard
abstract override fun remove(element: E): Boolean
Link copied to clipboard
abstract override fun removeAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract fun removeAt(index: Int): E
Link copied to clipboard
abstract fun removeBetween(indices: IntRange)
Link copied to clipboard
abstract fun removeChangeListener(listener: ListChangeListener<E>)
Link copied to clipboard
abstract fun removeListener(listener: InvalidationListener)
Link copied to clipboard
abstract override fun retainAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract operator fun set(index: Int, element: E): E
Link copied to clipboard
Link copied to clipboard
abstract override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
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.