kvision / pl.treksoft.kvision.state / ObservableListWrapper

ObservableListWrapper

class ObservableListWrapper<T> : MutableList<T>, ObservableList<T>, ObservableState<List<T>>

Simple observable list implementation.

Constructors

<init>

ObservableListWrapper(mutableList: MutableList<T> = mutableListOf())

Simple observable list implementation.

Properties

mutableList

val mutableList: MutableList<T>

onUpdate

val onUpdate: MutableCollection<(MutableList<T>) -> Unit>

size

val size: Int

Functions

add

fun add(element: T): Boolean
fun add(index: Int, element: T): Unit

addAll

fun addAll(elements: Collection<T>): Boolean
fun addAll(index: Int, elements: Collection<T>): Boolean

clear

fun clear(): Unit

contains

fun contains(element: T): Boolean

containsAll

fun containsAll(elements: Collection<T>): Boolean

get

fun get(index: Int): T

getState

fun getState(): List<T>

Get current state.

indexOf

fun indexOf(element: T): Int

isEmpty

fun isEmpty(): Boolean

iterator

fun iterator(): MutableIterator<T>

lastIndexOf

fun lastIndexOf(element: T): Int

listIterator

fun listIterator(): MutableListIterator<T>
fun listIterator(index: Int): MutableListIterator<T>

remove

fun remove(element: T): Boolean

removeAll

fun removeAll(elements: Collection<T>): Boolean

removeAt

fun removeAt(index: Int): T

retainAll

fun retainAll(elements: Collection<T>): Boolean

set

fun set(index: Int, element: T): T

subList

fun subList(fromIndex: Int, toIndex: Int): MutableList<T>

subscribe

fun subscribe(observer: (List<T>) -> Unit): () -> Unit

Subscribe for the state change notifications.

Extension Functions

createInstance

fun <T> Any?.createInstance(vararg args: dynamic): T

Helper function for creating JavaScript objects from dynamic constructors.

syncWithList

fun <T> MutableList<T>.syncWithList(list: List<T>): Unit

Utility extension function to synchronise elements of the MutableList.