| <html devsite="true"> |
| <head> |
| <title>StateObject</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <div itemscope="" itemtype="http://developers.google.com/ReferenceObject"> |
| <meta itemprop="name" content="StateObject"> |
| <meta itemprop="path" content="androidx.compose.runtime.snapshots"> |
| <meta itemprop="property" content="getFirstStateRecord()"> |
| <meta itemprop="property" content="mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)"> |
| <meta itemprop="property" content="prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)"> |
| <meta itemprop="language" content="JAVA"> |
| </div> |
| <div id="header-block"> |
| <div> |
| <h1>StateObject</h1> |
| </div> |
| <div id="metadata-info-block"> |
| <div id="source-link"><a href="https://cs.android.com/search?q=file:androidx/compose/runtime/snapshots/Snapshot.kt+class:androidx.compose.runtime.snapshots.StateObject&ss=androidx/platform/frameworks/support" class="external">View Source</a></div> |
| </div> |
| </div> |
| <div id="refdoc-switcher-placeholder"></div> |
| <p> |
| <pre>public interface <a href="/reference/androidx/compose/runtime/snapshots/StateObject.html">StateObject</a></pre> |
| </p> |
| <div class="devsite-table-wrapper"><devsite-expandable><span class="expand-control jd-sumtable-subclasses">Known direct subclasses |
| <div class="showalways" id="subclasses-direct"><a href="/reference/androidx/compose/runtime/snapshots/SnapshotStateList.html">SnapshotStateList</a>, <a href="/reference/androidx/compose/runtime/snapshots/SnapshotStateMap.html">SnapshotStateMap</a></div> |
| </span> |
| <div id="subclasses-direct-summary"> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/androidx/compose/runtime/snapshots/SnapshotStateList.html">SnapshotStateList</a></code></td> |
| <td> |
| <p>An implementation of <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html">MutableList</a></code> that can be observed and snapshot.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/compose/runtime/snapshots/SnapshotStateMap.html">SnapshotStateMap</a></code></td> |
| <td> |
| <p>An implementation of <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html">MutableMap</a></code> that can be observed and snapshot.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </devsite-expandable> </div> |
| <hr> |
| <p>Interface implemented by all snapshot aware state objects. Used by this module to maintain the state records of a state object.</p> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public methods</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>abstract @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a></code></td> |
| <td> |
| <div><code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#getFirstStateRecord()">getFirstStateRecord</a>()</code></div> |
| <p>The first state record in a linked list of state records.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>default <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a></code></td> |
| <td> |
| <div><code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)">mergeRecords</a>(<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> previous,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> current,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> applied<br>)</code></div> |
| <p>Produce a merged state based on the conflicting state changes.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>abstract void</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)">prependStateRecord</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> value)</code></div> |
| <p>Add a new state record to the beginning of a list.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="list"> |
| <h2>Public methods</h2> |
| <div class="api-item"><a name="getFirstStateRecord--"></a><a name="getfirststaterecord"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="getFirstStateRecord()">getFirstStateRecord</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">abstract @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> <a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#getFirstStateRecord()">getFirstStateRecord</a>()</pre> |
| <p>The first state record in a linked list of state records.</p> |
| </div> |
| <div class="api-item"><a name="mergeRecords(androidx.compose.runtime.snapshots.StateRecord, androidx.compose.runtime.snapshots.StateRecord, androidx.compose.runtime.snapshots.StateRecord)"></a><a name="mergeRecords-androidx.compose.runtime.snapshots.StateRecord-androidx.compose.runtime.snapshots.StateRecord-androidx.compose.runtime.snapshots.StateRecord-"></a><a name="mergerecords"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)">mergeRecords</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">default <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> <a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)">mergeRecords</a>(<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> previous,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> current,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> applied<br>)</pre> |
| <p>Produce a merged state based on the conflicting state changes.</p> |
| <p>This method must not modify any of the records received and should treat the state records as immutable, even the <code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)">applied</a></code> record.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> previous</code></td> |
| <td> |
| <p>the state record that was used to create the <code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)">applied</a></code> record and is a state that also (though indirectly) produced the <code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)">current</a></code> record.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> current</code></td> |
| <td> |
| <p>the state record of the parent snapshot or global state.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> applied</code></td> |
| <td> |
| <p>the state record that is being applied of the parent snapshot or global state.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Returns</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a></code></td> |
| <td> |
| <p>the modified state or <code>null</code> if the values cannot be merged. If the states cannot be merged the current apply will fail. Any of the parameters can be returned as a result. If it is not one of the parameter values then it <em>must</em> be a new value that is created by calling <code><a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html#create()">StateRecord.create</a></code> on one of the records passed and then can be modified to have the merged value before being returned. If a new record is returned <code><a href="/reference/androidx/compose/runtime/snapshots/MutableSnapshot.html#apply()">MutableSnapshot.apply</a></code> will update the internal snapshot id and call <code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)">prependStateRecord</a></code> if the record is used.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="api-item"><a name="prependStateRecord-androidx.compose.runtime.snapshots.StateRecord-"></a><a name="prependstaterecord"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)">prependStateRecord</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">abstract void <a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)">prependStateRecord</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/snapshots/StateRecord.html">StateRecord</a> value)</pre> |
| <p>Add a new state record to the beginning of a list. After this call <code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#firstStateRecord()">firstStateRecord</a></code> should be <code><a href="/reference/androidx/compose/runtime/snapshots/StateObject.html#prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)">value</a></code>.</p> |
| </div> |
| </div> |
| </body> |
| </html> |