candlefinance / faster-image

Fast image loading for React Native backed by performant native libraries.
https://candle.fi/discord
MIT License
594 stars 28 forks source link

[Request feature] Preload images #44

Closed ng-ha closed 3 weeks ago

ng-ha commented 5 months ago

Does this library support to preload images or plan to support this feature in the future?

gtokman commented 5 months ago

@ng-ha yes, it's pretty trivial to add. I'll have more time next week to do it.

// ios/FasterImageViewManager.swift
@objc
  func prefetch(_ sources: [String],
                resolve: @escaping RCTPromiseResolveBlock,
                reject: @escaping RCTPromiseRejectBlock) {
                do {
    let prefetcher = ImagePrefetcher()
    let urls = sources.map { url in URL(string: url )}.compactMap{ $0 }
    prefetcher.startPrefetching(with: urls)
    resolve(true)
    } catch { reject() }
  }
ducpt-bili commented 3 months ago

hi @gtokman , does the preload feature is working on this library? btw, Thank you for your great lib.

tconns commented 2 months ago

@gtokman I think 'sources' should have the type '{uri, header}[]'. Please implement the 'prefetch' feature, and I will contribute additional code for the Android platform.

nhuesmann commented 1 month ago

Is this feature being considered? It's an important one for me too

jieey1140 commented 1 month ago

Hopefully this feature will be added soon!

gtokman commented 3 weeks ago

Added prefretch in the latest version.