question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FR] Expand return type on imperative APIs

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
colinrtwhitecommented, Apr 13, 2020

@chrisbanes Ended up changing my mind on this 🙂. Implemented here: https://github.com/coil-kt/coil/pull/349 and will be part of the next release.

0reactions
colinrtwhitecommented, Feb 7, 2020

It’s probably simpler than that. See here for a quick impl.

Oh neat I didn’t know about OnChildPositioned.

Basically replicating what you did for Transition but for things which don’t use Drawables

Ah I see what you mean. My preference would be to integrate Coil’s Transition with the Compose Transition class if that’s possible. However, that doesn’t look likely at the moment… Going to play around with Compose more to improve my understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are Symbolic and Imperative APIs in TensorFlow 2.0?
TensorFlow 2.0 provides another symbolic model-building APIs: Keras Functional. Sequential is for stacks, and as you've probably guessed, ...
Read more >
Imperative Programming - Real World OCaml
Note that f must return unit , since it is expected to work by side effect rather than by returning a value, and...
Read more >
React Hooks Explained: useImperativeHandle
This form should consist of two fields: one for the user's name, and one for ... useImperativeHandle will return this object when the...
Read more >
RESTful web API design - Best Practices - Microsoft Learn
Learn the best practices for designing web APIs that support platform independence and service evolution.
Read more >
Effective Fart: Design - Fart programming language
PREFER a non-imperative verb phrase for a boolean property or variable. ... DO type annotate public APIs. DON'T specify a return type for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found