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: emit events for settings changes #312

Merged
merged 13 commits into from
Oct 17, 2024
Merged

feat: emit events for settings changes #312

merged 13 commits into from
Oct 17, 2024

Conversation

DNR500
Copy link
Contributor

@DNR500 DNR500 commented Oct 15, 2024

Jira: LF-10342

This PR as the settingUpdate event - this event will fire whenever the settings in the Widget are changed

Testing

Note: for testing I have been cherry-picking the addition of the WidgetEventsControl from the #309. its in this one commit. Once that PR is merged those changes will be available here as well

To test using the WidgetEventsControl

  • Open Playground, go to the Playground settings and turn on the Dev view option
  • The Widget events control should be visible in the playground
  • You can toggle on event listener for settingsUpdated
  • settingsUpdated event name with its payloads will be printed in the console

Using the event

To add a listener

widgetEvents.on(WidgetEvent.SettingUpdated, (payload) => console.log(payload))

The payload for the event will look like this...

{
  "setting": "slippage",
  "newValue": "0.4",
  "oldValue": "0.3",
  "newSettings": { ... } // all the settings values after the change
  "oldSettings": { ... } // all the settings values before the change
}

The above is for the slippage setting but each of the settings will emit an event when changed. This should cover - appearance, gasPrice, language, routePriority, enabledAutoRefuel, slippage, disabledBridges, enabledBridges, _enabledBridges, disabledExchanges, enabledExchanges and _enabledExchanges

@DNR500 DNR500 added the WIP Work in progress label Oct 15, 2024
@DNR500 DNR500 changed the title Settings event emit feat: emit events for settings changes Oct 15, 2024
@DNR500 DNR500 force-pushed the settings-event-emit branch from c63f618 to 8eba952 Compare October 15, 2024 13:13
@DNR500 DNR500 added testing and removed WIP Work in progress labels Oct 15, 2024
Copy link

Hey! This is your new endopint: https://b7cae349.widget-settingsev.pages.dev

);
},
[debouncedSetValue],
);
Copy link
Contributor Author

@DNR500 DNR500 Oct 16, 2024

Choose a reason for hiding this comment

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

Had to decouple the inputs value from setting the slippage value in the settings store a little. The debounce means setting the slippage value should happen once and not on each keystroke

Copy link

Hey! This is your new endopint: https://d3f5bd09.widget-settingsev.pages.dev

Copy link

Hey! This is your new endopint: https://e0759c6b.widget-settingsev.pages.dev

Copy link

Hey! This is your new endopint: https://c05b5e54.widget-settingsev.pages.dev

@chybisov chybisov merged commit cf48cf2 into main Oct 17, 2024
1 check passed
@chybisov chybisov deleted the settings-event-emit branch October 17, 2024 12:36
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