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

Allow Parallel Fetching of Multiple Locale Paths #776

Open
eliebman-godaddy opened this issue Jun 5, 2024 · 0 comments
Open

Allow Parallel Fetching of Multiple Locale Paths #776

eliebman-godaddy opened this issue Jun 5, 2024 · 0 comments

Comments

@eliebman-godaddy
Copy link
Contributor

eliebman-godaddy commented Jun 5, 2024

Problem

We have an application that waits for i18n to be fetched for multiple dependencies.
Nesting multiple withLocaleRequired HOCs causes these locale files to be fetched in series, which means longer load times.
Each withLocaleRequired blocks the subsequent one from rendering until it's own fetching is complete.

Example Code:

// compose is a utility that wraps a component in multiple HOCs

export default compose(
  withLocaleRequired('/i18n'),
  withLocaleRequired('/i18n/@scope-one/module-one'),
  withLocaleRequired('/i18n/@scope-two/module-two'),
  withLocaleRequired('/i18n/@scope-three/module-three'),
)(Component);

Proposed Solution

Allow withLocaleRequired to accept an array of paths, to be fetched in parallel.
The only component blocked from rendering will be the underlying Component, and all locale fetching can take place simultaneously within one single instance of withLocaleRequired.

Example Code:

const requiredLocalePaths = [
  '/i18n',
  '/i18n/modules/module-one',
  '/i18n/modules/module-two',
  '/i18n/modules/module-three'
]

export default withLocaleRequired(requiredLocalePaths)(Component);

Conclusion

A design that allows parallel fetching of many locale paths would speed up load times for our application significantly. I'm willing to work on this feature, but wanted to get feedback on the proposal first.

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

1 participant