Result
class Result<T : Any>(name: String, serializer: KSerializer<T>, stateHandle: SavedStateHandle, scope: CoroutineScope, json: Json = Json, default: T? = null, workerDispatcher: CoroutineDispatcher = Dispatchers.Default) : ViewModelState<T> (source)
Persists payloads; loading and errors are transient. Restored non-null data starts as Success.
Constructors
Link copied to clipboard
constructor(name: String, serializer: KSerializer<T>, stateHandle: SavedStateHandle, scope: CoroutineScope, json: Json = Json, default: T? = null, workerDispatcher: CoroutineDispatcher = Dispatchers.Default)
Properties
Functions
Link copied to clipboard
Clears the payload without disconnecting observers.
Link copied to clipboard
Maps payloads while preserving each result's status and error.
Link copied to clipboard
Link copied to clipboard
Synchronous projection for cheap work. Use selectAsync for expensive computations.
Link copied to clipboard
Computes an expensive derived state asynchronously; reads reuse its last completed value.
Link copied to clipboard
Synchronous write for small values. Throws on codec failure, preserving the prior state. Prefer setAsync for expensive payloads; this method runs on the calling thread.
Results without payload retain the last saved data; invalidate explicitly clears it.
Skips equal payload encoding while still resetting transient status.
Link copied to clipboard