Skip to content

[FR] Expand return type on imperative APIs #278

@chrisbanes

Description

@chrisbanes

Currently all of the imperative APIs return a Drawable, which is great for drawing but it would be handy to know more information about the load itself. Things like: where did the image come from? (cache? network?)

I imagine something like the transition API:

enum class Source { DISK, MEMORY_CACHE, NETWORK }

sealed class LoadResult {
    class Success(
        val drawable: Drawable,
        val source: Source
    ) : LoadResult()

    class Error(
        val drawable: Drawable?
    ) : LoadResult()
}
    
fun Coil.getResult(data: Any): LoadResult

This would be super useful for when Coil is being used in outside of View environments 🚀

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions