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 2 years ago • 3 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

Approve this PR please. I need this futures.

vicimpa avatar Nov 04 '24 22:11 vicimpa

Hey thanks for the contribution, you've changed a lot just to make return a stronger type – can you elaborate on why you've made the much larger changes?

joshuaellis avatar Nov 07 '24 08:11 joshuaellis

no, i barely remember doing this! 🙃

benwest avatar Nov 07 '24 13:11 benwest