Interface MutableState<T>
- Type Parameters:
T- the value type
- All Superinterfaces:
State<T>,StateToken
- All Known Implementing Classes:
InitialStateImpl,MutableStateImpl
Mutable per-context state. Writes are main-thread only and mark watching components
dirty; dirty tokens flush coalesced at the end of the current engine entry point.
-
Method Summary
Modifier and TypeMethodDescriptionvoidset(@NotNull ViewContext context, T value) Writes this token's value for the given context and marks watchers dirty.voidupdate(@NotNull ViewContext context, @NotNull UnaryOperator<T> fn) Read-modify-write convenience: appliesfnto the current value and stores the result.
-
Method Details
-
set
Writes this token's value for the given context and marks watchers dirty.- Parameters:
context- an active context of the owning viewvalue- the new value, possiblynull- Throws:
StaleContextException- when the context belongs to another view or is closedIllegalStateException- when called off the main thread
-
update
Read-modify-write convenience: appliesfnto the current value and stores the result. Main thread only.- Parameters:
context- an active context of the owning viewfn- the function producing the new value from the current one; invoked exactly once on the current value. Side effects inside fn are safe (unlikeSharedState.update(java.util.function.UnaryOperator<T>))- Throws:
StaleContextException- when the context belongs to another view or is closedIllegalStateException- when called off the main thread
-