-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:preload callbacks #995
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # android/src/main/java/com/dylanvann/fastimage/FastImagePreloaderModule.java # src/index.d.ts # src/index.js
…preload-callbacks
Update from original repository
Sync with the original repo
…allbacks-fetch-updates-2021-08-18
…dd callback to preload function
…-fetch-updates-2021-08-18 Feature/preload callbacks fetch updates 2021 08 18
Hey @DylanVann, it would be nice to have this one merged. What do you think? |
@DylanVann can you please merge this? It would be very helpful |
@nicomontanari would you be able to help me on adding this PR to my react native project? I have tried downloading the stable version of react-native-fast-image and applying the necessary changes to the files, but I am not able to get it working. |
|
This PR is missing the runtime change needed in Instead replace with: FastImage.preload = (sources, onProgress, onComplete) =>
preloaderManager.preload(sources, onProgress, onComplete) |
Hi @akeva001, i'm sorry for the delay in my response. First i added this line in the "dependecies" section in the Then this is how i implemented the preload: import FastImage from 'react-native-fast-image/src'
const preload = async (images: string[]): Promise<void> => {
return new Promise<void>(async (resolve, reject) => {
FastImage.preload(
images.map((image) => ({
uri: image
})),
(finished, total) => {
if (__DEV__) {
console.log('Preload:', `f ${finished}/t ${total}`)
}
},
(_, skipped) => {
if (skipped > 0) {
reject(skipped)
if (__DEV__) {
console.log('Preload: failed with skipped ', skipped)
}
}
if (__DEV__) {
console.log('Preload: finish')
}
resolve()
}
)
})
} |
@sterlingwes i'm sorry but i didn't understand your comment. These changes already implement your piece of code. |
@nicomontanari if you look in the PR diff here and scroll to the very bottom you'll see that you only have typescript changes in You need to update the index file to pass those params into the method exposed by PreloaderManager which isn't currently used in this diff. |
android/src/main/java/com/dylanvann/fastimage/FastImagePreloaderListener.java
Outdated
Show resolved
Hide resolved
…erListener.java Co-authored-by: Wes Johnson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like src/index.tsx:260
needs some changes to use the new interface
@frg100 @sterlingwes thanks for the tip, I missed these changes along the way 😕 |
I opened another pull request because the previous one was unexpectedly closed.
@DylanVann I have been using these changes in production for 1 year and everything works fine.