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

Open
wants to merge 7 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%)

@dbrans dbrans marked this pull request as ready for review February 25, 2025 13:31
@dbrans dbrans requested review from a team as code owners February 25, 2025 13:31
@metamaskbot
Copy link
Collaborator

Builds ready [c082a29]
Page Load Metrics (1613 ± 86 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint35922041474408196
domContentLoaded14012180159017484
load14062208161318086
domInteractive24153473215
backgroundConnect86229178
firstReactRender1368302110
getState466192311
initialActions01000
loadScripts9781667115414871
setupStore75511105
uiStartup16212494183320096
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 313 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [8aae873]
Page Load Metrics (1495 ± 43 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint42216891442251120
domContentLoaded1295166214758842
load1303169114959043
domInteractive2194412311
backgroundConnect106326157
firstReactRender135921147
getState56113178
initialActions01000
loadScripts932126410798039
setupStore76414168
uiStartup1505188016949546
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 313 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [fbcb67b]
Page Load Metrics (1791 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint36021691720350168
domContentLoaded15782155176715876
load15882172179115976
domInteractive26121593115
backgroundConnect108432209
firstReactRender1476392512
getState56215157
initialActions01000
loadScripts11041586130513063
setupStore85820189
uiStartup18292470204016278
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 318 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [d147959]
Page Load Metrics (1656 ± 84 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint13911928164916680
domContentLoaded13841890162516177
load13921950165617484
domInteractive247639178
backgroundConnect1090342211
firstReactRender1371372411
getState46820209
initialActions01000
loadScripts10101461120114268
setupStore77317199
uiStartup16022205188118991
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 318 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