react-native-link-preview
react-native-link-preview copied to clipboard
Feature request - Caching
When you put multiple link preview components to the screen with same link, then it makes multiple fetches to the link. In our use case we could have thousands of previews with same link
Hmm where I would store the cache given the component can be placed anywhere, including lists? The cache makes sense on the app level, but on the library level, not sure.. I will need async storage or something, but this is a native dependency, plus some people use alternative like mmkv. Do you have ideas how this can be implemented?
@demchenkoalex I know this is late and to be honest a cache can be more trouble then good but what about a InMemoryCache like apollo graphql
will not work on this in the foreseeable future :/
just an idea on implementing this without native dependencies and giving user flexibility: https://docs.pmnd.rs/zustand/integrations/persisting-store-data zustand essentially allows you to pass in an object that defines the get set and remove cach functions and it handles them accordingly on startup and during use. To make it simpler for this library you could just have an optional prop instead of a wrapper cacheHandler={{getItem:AsyncStorage.getItem, setItem:AsyncStorage.setItem, removeItem:AsyncStorage.removeItem, key: 'nameOfCache'}} with getItem(key+otherconfig) called on mount. and setItem(key+otherconfig) called onPreviewDataFetched.