GithubHelp home page GithubHelp logo

Comments (9)

kfiroo avatar kfiroo commented on May 23, 2024 1

@iegik Hey, thanks for the detailed response! :)

I agree that it will provide us with amazing customization capabilities for ImageCacheProvider that are now not so straight forward.

Taking this to a more practical level, I think we could have our stand alone ImageCacheManager (what we call today ImageCacheProvider) that should be used by ImageCacheProvider component that should reside at the top of your app and define the Cache behaviour.

The ImageCacheProvider would provide the customized ImageCacheManager to all CachedImages that are in its subtree using the context.

One could still use the stand alone API and provide his own customizations, same as today.

What do you think?

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024 1

Created a v1.4 branch, I'll push some more changes today, then I'll create a PR for it and we could continue the discussion over there :)

Sounds good?

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024

@iegik Hey
You could actually use the ImageCacheProvider to do various actions.

I feel like the CachedImage component is the simplest way to cache images, it's a simple drop-in replacement for the Image component and works great out of the box.
For some more advanced use cases you can use the ImageCacheProvider and cache some urls when the app starts or clean the cache.

Why do you think having the CachedImageProvider as a component is better?

from react-native-cached-image.

iegik avatar iegik commented on May 23, 2024

Here I want to compare ImageCacheProvider with NavigationProvider or StyleProvider. I assume, that is possible create such Provider, who watches on its children`s and do some staff on their`s properties:

<ImageCacheProvider>
    <Image .../>
    <image .../>
</ImageCacheProvider>

So, I think CachedImageProvider - can be also a component.
I understand, that You want to separate logic for rendering image and caching that image.

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024

The problems I see with this is that the Images would have to be immediate children of the ImageCacheProvider and I, personally, wouldn't like it in my code.
Moreover, this pattern is mostly used as a way to provide a certain behaviour to an entire sub-tree by passing some functionality through the context and again I'm not sure this is the case here.

What are the pros of this kind of a solution? What can we gain that is currently not possible?

from react-native-cached-image.

iegik avatar iegik commented on May 23, 2024

The problems I see with this is that the Images would have to be immediate children

Ok, You are right here.

pattern is mostly used as a way to provide a certain behaviour to an entire sub-tree

Benefit of this pattern - You can always (enable) cache or pass (disable) caching by changing property of "caching provider". It is abstract layer for image loading mechanism.

it's a simple drop-in replacement for the Image component and works great out of the box

I found, that removing loading template out of the box and rendering method - will make CachedImage component much lighter. But why CachedImage? we just need make transparent only one component to provide basic functionality out-of-the-box!
Let's do it in "Provider"!?

Here is some variants of usage (I apologize for #61 (comment)):

  1. Using provider for each Image
<ImageCacheProvider source={image}>
    <Image source={image} />
</ImageCacheProvider>
  1. Make own CachedImage
let CachedImage = (props) => {
    let {sources} = props;
    return <CachedImageProvider sources={[...images]} renderImage={props => (
        <ResponsiveImage {...props} />
    )} />
}

<CachedImage sources={...}/>
  1. Preloader for some cases
<ImageCacheProvider sources={[...images]}/>
...
<Image/>
<Image/>
...

from react-native-cached-image.

iegik avatar iegik commented on May 23, 2024

MB, git flow init -d and create v1.4 branch?

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024

@iegik what does that do?

from react-native-cached-image.

iegik avatar iegik commented on May 23, 2024

https://github.com/nvie/gitflow

from react-native-cached-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.