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, the three states carry the last known data alongside them, so a refresh or 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 active profile or the language changes, the SDK drops what it held, so a Failure following such a change carries no data. 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: Date = Date()) : 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: Date = Date()) : CgsStreamState<T>

The request came back.

Functions

Link copied to clipboard

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