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

create a README for the LocalizeMixin #102

Merged
merged 10 commits into from
Jun 12, 2019
Merged

create a README for the LocalizeMixin #102

merged 10 commits into from
Jun 12, 2019

Conversation

margaree
Copy link
Contributor

@margaree margaree commented Jun 4, 2019

Much of this is copied from the d2l-localize-behavior, with mostly the usage and language resources being updated.

mixins/localize-mixin.md Outdated Show resolved Hide resolved
@margaree
Copy link
Contributor Author

margaree commented Jun 5, 2019

Changes made:

  • Simplification of getLangResources implementation within components
  • Components will define namespaceBase property value (e.g., more-less)
  • Cache is completely handled in localize-mixin.js
  • this.__resources was removed - because of this it became necessary to call requestUpdate() since __resources changing triggered render (let me know if I used this incorrectly)

}
this._onRequestResponse(res, this.__language);
});
this.__namespace = `${this.__namespaceBase}:${this.__language}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be this.namespaceBase (without the double underscores)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it definitely should

mixins/localize-mixin.md Outdated Show resolved Hide resolved
@margaree
Copy link
Contributor Author

Recent changes:

  • removed the cache from LocalizeMixin (it wasn't really providing any performance improvements)
  • removed the need for both getLanguage and getLangResources
  • renamed getLangResources to getLocalizeResources and made it static

I haven't updated the localize mixin readme yet to reflect these changes in case there is more churn

this._onRequestResponse(res, this.__language);
this.__language = Object.keys(res)[0];
this.__resources = {};
this.__resources[this.__language] = res[this.__language];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ the way I did this was weird. will change.

@margaree
Copy link
Contributor Author

Any additional feedback on this?

Copy link
Member

@dlockhart dlockhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks a lot simpler than before!

Copy link
Contributor

@dbatiste dbatiste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to distract from the original purpose of this PR, but just want to throw something out there...

Currently, the localize mixin adds an observer to the document for each instance where the mixin is used. I'm not sure if this is a concern or not...?

In contrast, the Polymer DirMixin creates a single global observer, and the instances of the mixin add/remove a callback when connected/disconnected. For our Lit RtlMixin I chose not to do this, keeping in mind that we might add it if we wanted to handle dir attribute changes after the initial page-load. It's an approach we could take for the localize mixin, but I'm not sure if it's needed.

@dlockhart
Copy link
Member

@dbatiste Agreed. Worth throwing that into an Issue so we don't forget about it?

@margaree margaree merged commit f4a61d0 into master Jun 12, 2019
@margaree margaree deleted the localize-readme branch June 12, 2019 15:50
@dbatiste
Copy link
Contributor

Sounds good - thx Margaree... you beat me to it. ;)

@svanherk
Copy link
Contributor

This looks great, lots of nice detail!

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

Successfully merging this pull request may close these issues.

None yet

4 participants