This might be a dumb quesiton, but in the compose sample for produceState, there is an initial value of Result.Loading, what Result type is being used in the samples that include the .Loading member? I haven't been able to find a Result type to import with that support and want to avoid making a new one if it already exists somewhere
produceState: convert non-Compose state into Compose state
Copy code
@Composable
fun loadNetworkImage(
url: String,
imageRepository: ImageRepository
): State<Result<Image>> {
// Creates a State<T> with Result.Loading as initial value
// If either `url` or `imageRepository` changes, the running producer
// will cancel and will be re-launched with the new keys.
return produceState(initialValue = Result.Loading, url, imageRepository) {
k
Kevin Aude
11/02/2021, 8:51 AM
I may be wrong but I think this Result class is just a sealed class used to model the current state of a given operation. I haven’t seen anything coming from Compose directly, so I’d say you have to implement it yourself.
a
Andy Himberger
11/02/2021, 8:03 PM
Right seems that way, though Result<Image> is a real type, maybe their Result<T> is not the kotlin standard one, or they have some extensions