Skip to content
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

Make loadable.preload() return a promise #285

Closed
luishdz1010 opened this issue Mar 23, 2019 · 3 comments
Closed

Make loadable.preload() return a promise #285

luishdz1010 opened this issue Mar 23, 2019 · 3 comments

Comments

@luishdz1010
Copy link

🚀 Feature Proposal

Make loadable.preload() return a promise

Motivation

I'm implementing a "prefetcher" that will, depending on some conditions, request a bunch of known loadable components from an "index" object whose keys are strings and values loadable-components. At some point, I call preload on a bunch of these and I need a way to await on the loading promise of all components, seems like the only change necessary is to add a return statement at the end of the preload() function.

Pitch

To be honest, I kind of expected this to work, I was surprised preload() returns undefined.

@theKashey
Copy link
Collaborator

There is a long discussion, and the solution you are looking for - #226

@gregberge
Copy link
Owner

Hello @luishdz1010, .preload() is a "preload" action so it can't return a promise. If we expose this API, it will be under .load(). But I think it is not the good approach to take, with "Suspense" you will not be able to wait for component to be loaded this way. I suggest you to create your own load method if you want to do it. I prefer to wait for Suspense before adding this kind of API.

@luishdz1010
Copy link
Author

My bad for not looking hard enough 🤦‍♂️, thanks for the quick reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants