osamaqarem/react-native-image-colors

Cached Images Support

Closed this issue ยท 7 comments

It would be great if this supported cached images (just like react-native-fast-image)

I'm not sure I understand. Can you please clarify on how would that work?

So, a simple example: When passing an URL to getColors() the response image would be cached for the first time the request was made and future requests wouldn't be necessary since the image is cached. How it would work:

getColors(url) {
    if (url is in cache) {
         return colors from the cached image
    } else {
         make the request, cache the image, return the colors
    }
}

this would be the logic.

Another idea that I came up with
Something that would be nice too is adding react-native-fast-image cached images support. I came up with this idea because I'm making a music app. It uses react-native-fast-image quite a lot and since the images that I use with getColors() are already cached, why would I need to request them once more to the server? Or even images that are cached by react-native by default when using Image. This would require a little extra work I assume, but only the part of caching images would be already a great addition to this package because it is efficient and time-saving.

If I made myself unclear at some point, feel free to ask, I'll do my best to explain it better

Thanks, I understand. Good idea. I'll try to look into this.

Hey @gustavo-dev. I briefly looked into this and I think the image component that ships with React Native does not expose any method to get the cached image.

For react-native-fast-image, once this pull request is merged, we will be able to get the image path from cache.

However, I think its better if we leave it up to the user to install and use Fast Image since it is a 3rd party library. But we could mention something about it in the README here as a tip.

When will it be merged?

Its up to the authors of FastImage

Oh, I didn't realize this pull request was on the FastImage repo, but thanks anyway.