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(ui): reduce suggestedParams requests #120

Merged
merged 7 commits into from
May 3, 2024
Merged

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented May 2, 2024

The generated Algokit app clients will fetch suggested transaction params for every transaction, unless you provide them yourself via the params property. To prevent frequent repeated requests for the same data, this adds a simple utility class called ParamsCache which fetches suggested params once and caches the result for a configured staleTime (currently 5 minutes).

While this does mean I'm now instantiating app clients via an async function, since the data is cached most of those executed functions will return their data instantly.

Other Changes

My initial approach here was to use Tanstack Query for fetching and caching suggested params. But it would require passing a QueryClient instance as an argument to every API function from the component calling it. Over the course of my first approach I made some other minor changes, including:

  • renaming algod API functions starting with get to fetch to follow the convention used everywhere else
  • moving the functions that return app client instances to a separate file: /src/api/clients.ts

Even though I reverted the commit that actually added the query, the other changes could obviously stay.

Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
reti ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 7:13am

drichar added 3 commits May 3, 2024 02:59
@drichar drichar merged commit 79d14f3 into dev May 3, 2024
3 checks passed
@drichar drichar deleted the feat/ui-suggested-params branch May 3, 2024 07:36
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.

1 participant