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

refactor: introduce useAsyncCallback and simplify useAsyncResult #30538

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dbrans
Copy link
Contributor

@dbrans dbrans commented Feb 24, 2025

Description

This PR introduces useAsyncCallback for manual execution of asynchronous functions (e.g., on button clicks) with state management (idle, pending, success, error). useAsyncResult is refactored to build upon useAsyncCallback. This separates concerns of manual execution from automatic execution on mount/update.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-extension-platform Extension Platform team label Feb 24, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [54b5dc5]
Page Load Metrics (1714 ± 66 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14701937170614067
domContentLoaded14611907167913364
load14801973171413766
domInteractive26230545124
backgroundConnect9106392412
firstReactRender157324167
getState566262311
initialActions01000
loadScripts10501483125113062
setupStore87016189
uiStartup17552207195214469
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: -70 Bytes (-0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [9c994ee]
Page Load Metrics (1788 ± 84 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22122731711385185
domContentLoaded14972238175916479
load15102258178817584
domInteractive28164573818
backgroundConnect1097312110
firstReactRender1572362311
getState56017168
initialActions01000
loadScripts11051664130912359
setupStore75819188
uiStartup16722522202117885
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 161 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-extension-platform Extension Platform team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants