CgsStreamState

sealed interface CgsStreamState<out T>

The state of an observed value: what the SDK currently holds, and what it is doing about it.

This is what every get(id, scope) emits. Unlike a plain success-or-failure, a failure can still carry the last known data, so a network blip never has to blank the screen:

CGS.content().issues.get(issueId, viewModelScope).collect { state ->
when (state) {
is CgsStreamState.Refreshing -> { state.data?.let(::render); showSpinner() }
is CgsStreamState.Success -> { render(state.data); hideSpinner() }
is CgsStreamState.Failure -> {
state.data?.let(::render) // keep the stale value on screen
showError(state.cgsError)
}
}
}

One exception: after the signed-in account or the active profile changes, the SDK drops what it held, so a Failure following such a change carries at most what was cached for the new session. It is never one profile's content shown under another's.

Parameters

T

the observed value.

Inheritors

Types

Link copied to clipboard
data class Failure<T>(val cgsError: CgsError, val data: T? = null, val failedAt: Instant = Clock.System.now()) : CgsStreamState<T>

The request failed.

Link copied to clipboard
data class Refreshing<T>(val data: T? = null) : CgsStreamState<T>

A request is in flight.

Link copied to clipboard
data class Success<T>(val data: T, val succeededAt: Instant = Clock.System.now()) : CgsStreamState<T>

The request came back.

Functions

Link copied to clipboard

This state as a Refreshing one, keeping whatever data it holds.