Comments (9)
@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 CachedImage
s 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.
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.
@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.
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.
The problems I see with this is that the Image
s 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.
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)):
- Using provider for each
Image
<ImageCacheProvider source={image}>
<Image source={image} />
</ImageCacheProvider>
- Make own
CachedImage
let CachedImage = (props) => {
let {sources} = props;
return <CachedImageProvider sources={[...images]} renderImage={props => (
<ResponsiveImage {...props} />
)} />
}
<CachedImage sources={...}/>
- Preloader for some cases
<ImageCacheProvider sources={[...images]}/>
...
<Image/>
<Image/>
...
from react-native-cached-image.
MB, git flow init -d
and create v1.4 branch?
from react-native-cached-image.
@iegik what does that do?
from react-native-cached-image.
https://github.com/nvie/gitflow
from react-native-cached-image.
Related Issues (20)
- Not working on the snack.expo.io platform HOT 1
- ImageCachePreloader does not work on first time preloading HOT 2
- The code in example does NOT really clear the cache
- Netinfo error HOT 11
- Open image in modal
- RN 0.60 support HOT 4
- Update TypeScript types to reflect examples. HOT 1
- Change dependency react-native-fetch-blob to rn-fetch-blob as the previous repo has been achieved HOT 2
- componentWillReceiveProps [Deprecated]
- NetInfo is deprecated from react-native use from @community HOT 9
- Replace react-native-fetch-blob with rn-fetch-blob
- Crashes in release on 0.60
- webp support for image?
- netinfo has been removed from react-native HOT 8
- Update Readme HOT 1
- Please remove this issue
- Getting double borders HOT 1
- Error on hermes engine: DocumentDir of null
- separate netinfo from React native & import from react native community
- Import Netinfo from react native community
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-cached-image.