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

action.onUserSettingsChanged proposal #499

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

EmiliaPaz
Copy link
Contributor

Proposal based on #346: New API: UserSettings.isOnToolbar change event

@bershanskiy
Copy link
Member

This API permits addition of new observers, but not removal of old ones: action.onUserSettingsChanged().

Instead, it could match the established pattern of <eventName>.addListener() and <eventName>.removeListener() and become action.onUserSettingsChanged.addListener() and action.onUserSettingsChanged.removeListener().

@oliverdunk
Copy link
Member

Instead, it could match the established pattern of <eventName>.addListener() and <eventName>.removeListener()

Thanks for the callout. I'll make sure @emilia-paz sees this but I suspect it is just a mistake in the proposal. We would almost certainly want to follow the normal event listener pattern here :)

@oliverdunk
Copy link
Member

@zombie / @dotproto / @xeenon - could you take a look at this?

Copy link
Member

@Rob--W Rob--W 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. Just one question, which is mainly relevant for the future implementation (and current documentation).

proposals/action-on-user-settings-changed-api.md Outdated Show resolved Hide resolved
```javascript
// Fires when user-specified settings relating to an extension's action changed.
<browser>.action.onUserSettingsChanged.addListener(
callback: function, // where callback looks like: (userSettings: UserSettings) => void
Copy link
Member

Choose a reason for hiding this comment

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

The type of the event parameter is identical to the return value of getUserSettings. Is that an intentional design?

With the current proposal consisting of one property only, it does not make that much of a difference. Once multiple events get added, the answer depends on the design decision:

  • If we want to always include the latest value of all settings, then we can use the same type as the event parameter to onUserSettingsChanged listeners and as the return value of getUserSettings.
  • If we want to only include modified values, then we need a new type that looks like onUserSettingsChanged, but with all fields optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! We think it's more valuable to the user to only return the modified values. Updated the proposal

proposals/action-on-user-settings-changed-api.md Outdated Show resolved Hide resolved
@Rob--W Rob--W merged commit 77e5045 into w3c:main Feb 1, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Feb 1, 2024
SHA: 77e5045
Reason: push, by Rob--W

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Feb 1, 2024
SHA: 77e5045
Reason: push, by Rob--W

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to patrickkettner/webextensions that referenced this pull request Feb 14, 2024
SHA: 77e5045
Reason: push, by patrickkettner

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to patrickkettner/webextensions that referenced this pull request Feb 14, 2024
SHA: 77e5045
Reason: push, by patrickkettner

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

5 participants