Patch

sealed class Patch<out T>

A Patch describes the changes made to a List.

Pay attention that the sealed implementations should not be data classes - each generated patch must be applied in every case even though it might "equal" the preceding one. (Imagine deleting the first item of a list at least twice!) Using data classes patches could quite easily become equal and then might be dropped by mountSimple! Thus, it is intentional to implement those as regular classes.

Inheritors

Types

Link copied to clipboard
class Delete<T>(val start: Int, val count: Int = 1) : Patch<T>

A Patch saying, that one or more elements have been deleted

Link copied to clipboard
class Insert<T>(val element: T, val index: Int) : Patch<T>

A Patch saying, that a new element has been inserted

Link copied to clipboard
class InsertMany<T>(val elements: List<T>, val index: Int) : Patch<T>

A Patch saying, that a several element have been inserted

Link copied to clipboard
class Move<T>(val from: Int, val to: Int) : Patch<T>

A Patch saying, that an element has been moved from one position to another. This is only used on mounts with a corresponding IdProvider.

Functions

Link copied to clipboard
abstract fun <R> map(parentJob: Job, mapping: (T, Job) -> R): Patch<R>

a convenience-method, to map the values encapsulated in a Patch