suspend-react icon indicating copy to clipboard operation
suspend-react copied to clipboard

Strong return type when passing a bare Promise; return promise from preload

Open benwest opened this issue 1 year ago • 0 comments

Hi! Very good and wonderful library, I made some changes to suit my project, maybe they're helpful?

  • Return type is now inferred when passing a bare Promise
  • preload now returns the cached Promise, so you can know when preloading is done

I would love to see the second change in particular propagate out to @react-three/fiber's useLoader, drei's useTexture etc! It allows more strategic preloading of assets (wait for high-priority assets to load before loading others).

This works in my project but I definitely haven't tested it exhaustively.

benwest avatar Oct 24 '23 15:10 benwest