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

Resources request pending while localize already called #143

Open
HJK181 opened this issue Nov 14, 2018 · 0 comments
Open

Resources request pending while localize already called #143

HJK181 opened this issue Nov 14, 2018 · 0 comments

Comments

@HJK181
Copy link

HJK181 commented Nov 14, 2018

Description

I'm using the starter kit app where I pass the current language to all views within the shell. All views extend a mixin which loads the langauge resources for the current view in an observer of the language property:

 _languageChanged(currentLang, oldLang) {
        if (currentLang) {
          const viewName = this.getAttribute('name');
          this.loadResources(this.resolveUrl(`locales/${currentLang}/${viewName}.json`), currentLang);          
        }
      }

Now I find myself in situation where a call to this.localize returns undefined because the network request loading the language resources is still pending, while the view is being visible. The only solution I found so far is to wrap the whole view inside a

<template is="dom-if" if="{{resources}}">
 ...
</template>

And add an additional check to observers:

_currentChanged(visible, resources) {
  if (visible && resources) {
    this.localize(...)
 }
}

Isn't there a better solution then differing rendering until the locale resources are loaded?

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