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

feat: call listeners after other important attributes change #95

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

margaree
Copy link
Contributor

No description provided.

@@ -121,6 +121,7 @@ class DocumentLocaleSettings {
}
}
this._overrides = val;
this._listeners.forEach((cb) => cb());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I wasn't sure of a completely ideal way to do all this. Since overrides, language, and fallbackLanguage can technically get changed through .fallbackLanguage etc., they should call the listeners, so I didn't want to duplicate that in _handleObserverChange, but it feels a bit weird to have two different ways that the calls are happening.

@@ -124,61 +124,98 @@ describe('common', () => {

describe('document mutations', () => {
it('should update language if "lang" gets set', (done) => {
documentLocaleSettings.addChangeListener(() => {
const cb = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since afterEach was resetting the attributes, these listeners were getting called again, causing an error about done being called multiple times.

@margaree margaree marked this pull request as ready for review November 26, 2021 20:23
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.

This looks good to me! Only question in my mind is whether we should be wrapping timezone and oslo in setters like the others and calling the listeners from there, but both approaches work.

@margaree margaree merged commit 69e69d4 into main Nov 29, 2021
@margaree margaree deleted the call-listeners-on-locale-changes branch November 29, 2021 13:23
@ghost
Copy link

ghost commented Nov 29, 2021

🎉 This PR is included in version 3.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ghost ghost added the released label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants