Skip to content

Allow Parallel Fetching of Multiple Locale Paths #776

@eliebman-godaddy

Description

@eliebman-godaddy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions