androidx.compose.frames

Classes

AbstractRecord

Base implementation of a frame record

Frame

Information about a frame including the frame id and whether or not it is read only.

ModelList

ModelMap

Exceptions

FrameAborted

Type-aliases

FrameCommitObserver

FrameReadObserver

FrameWriteObserver

Top-level functions summary

Unit?
_created(framed: Framed)

Record
_readable(r: Record, framed: Framed)

Record
_writable(r: Record, framed: Framed)

Unit

Abort the current frame.

Unit
abort(frame: Frame)

Abort the given frame and throw a FrameAborted exception.

Unit

Abort the current frame if one is open.

Unit

Abort the given frame.

Unit

Commit the current pending frame.

Unit
commit(frame: Frame)

Commit the given frame.

Unit?

Frame

Return the thread's active frame.

ModelList<T>

ModelList<T>
modelListOf(element: T)

ModelList<T>
modelListOf(vararg elements: T)

ModelMap<K, V>

ModelMap<K, V>
modelMapOf(vararg pairs: Pair<K, V>)

Unit
observeAllReads(readObserver: FrameReadObserver, block: () -> Unit)

FrameReadObserver will be called for every frame read happened on the current thread during execution of the block.

Frame
open(readOnly: Boolean = false)

Open a frame

Frame
open(readObserver: FrameReadObserver? = null, writeObserver: FrameWriteObserver? = null)

Open a frame with observers

T
T.readable(framed: Framed)

() -> Unit

Unit
restore(frame: Frame)

Restore the given frame to the thread.

Frame

Suspend the given frame.

Boolean
wasModified(value: Any)

Returns true if the given object framed object mutated in the the frame

T
T.writable(framed: Framed)

T
T.writable(framed: Framed, frame: Frame)

Return a writable frame record for the given record.

Top-level properties summary

Boolean

Top-level functions

_created

fun _created(framed: Framed): Unit?

_readable

fun _readable(
    r: Record,
    framed: Framed
): Record

_writable

fun _writable(
    r: Record,
    framed: Framed
): Record

abort

fun abort(): Unit

Abort the current frame. Throws FrameAborted if a frame is open. Throws IllegalStateException if no frame is open (use abortHandler to abort a frame without throwing an exception or to abort a frame if one is open).

abort

fun abort(frame: Frame): Unit

Abort the given frame and throw a FrameAborted exception.

abortHandler

fun abortHandler(): Unit

Abort the current frame if one is open. This is intended to be used in a catch handler to abort the frame and then rethrow the exception.

abortHandler

fun abortHandler(frame: Frame): Unit

Abort the given frame.

commit

fun commit(): Unit

Commit the current pending frame. Throws FrameAborted if changes in the frame collides with the current committed frame. Throws IllegalStateException no frame is open (use commitHandler() to commit a frame if one is open).

commit

fun commit(frame: Frame): Unit

Commit the given frame. Throws FrameAborted if changes in the frame collides with the current committed frame.

commitHandler

fun commitHandler(): Unit?

currentFrame

fun currentFrame(): Frame

Return the thread's active frame. This will throw if no frame is active for the thread.

modelListOf

fun <T> modelListOf(): ModelList<T>

modelListOf

fun <T> modelListOf(element: T): ModelList<T>

modelListOf

fun <T> modelListOf(vararg elements: T): ModelList<T>

modelMapOf

fun <K, V> modelMapOf(): ModelMap<K, V>

modelMapOf

fun <K, V> modelMapOf(vararg pairs: Pair<K, V>): ModelMap<K, V>

observeAllReads

fun observeAllReads(
    readObserver: FrameReadObserver,
    block: () -> Unit
): Unit

FrameReadObserver will be called for every frame read happened on the current thread during execution of the block.

open

fun open(readOnly: Boolean = false): Frame

Open a frame

Parameters
readOnly: Boolean = false true if the frame can only be read from
Return
the newly created frame's data

open

fun open(
    readObserver: FrameReadObserver? = null,
    writeObserver: FrameWriteObserver? = null
): Frame

Open a frame with observers

readable

fun <T : Record> T.readable(framed: Framed): T

registerCommitObserver

fun registerCommitObserver(observer: FrameCommitObserver): () -> Unit

restore

fun restore(frame: Frame): Unit

Restore the given frame to the thread.

suspend

fun suspend(): Frame

Suspend the given frame. After calling suspend() the thread's no longer has an open frame. Call restore() to restore a suspended thread.

wasModified

fun wasModified(value: Any): Boolean

Returns true if the given object framed object mutated in the the frame

writable

fun <T : Record> T.writable(framed: Framed): T

writable

fun <T : Record> T.writable(
    framed: Framed,
    frame: Frame
): T

Return a writable frame record for the given record. It is assumed that this is called for the first framed record in a frame object. If the frame is read-only calling this will throw. A record is writable if it was created in the current writable frame. A writable record will always be the readable record (as all newer records are invalid it must be the newest valid record). This means that if the readable record is not from the current frame, a new record must be created. To create a new writable record, a record can be reused, if possible, and the readable record is applied to it. If a record cannot be reused, a new record is created and the readable record is applied to it. Once the values are correct the record is made live by giving it the current frame id.

Top-level properties

inFrame

val inFrame: Boolean