Open
Description
Let's collect and decide on the uses cases and features we want to support with Async Library, either directly or through a separate package. They are grouped, but in no particular order. Core would be @async-library/core
, Integrations would be e.g. @async-library/react-hook
. User provided would be through passing a prop/option. Plugins would be separate packages.
⚙️ Core
- Handle race conditions in subsequent requests.
- Metadata to show started time / last fetched time / request duration and keep track of number of runs.
- Manual (re)start.
- Optimistic updates (set data to expected value before the promise settles).
- AbortController integration (create one on every start and pass it along).
- Run a function when the promise resolves or rejects (and the ability to define it just-in-time).
- Ability to append new data to the old data (e.g. infinite scroll).
- Global access to all instances, including their state and actions, and the option to (temporarily) override them from DevTools.
- Gracefully handle infinite loops.
- Support subscriptions (e.g. GraphQL, websockets, messagechannels, generators).
- Pass arguments when invoking the async function manually (i.e.
run(arg1, arg2)
, to support dynamic requests). - Allow polling for updates, alongside performing actions (i.e. enable reload of promiseFn while also using deferFn).
- Support resolving data synchronously, e.g. from a cache, to avoid rerendering.
- Allow custom concurrency strategies (e.g. ignore new fetches, cancel old fetches, queue new fetches, fetch all in parallel, fetch once and never again)
- Allow things like circuit breakers and retry with exponential backoff
🧩 Integration
- Await any promise / thenable or async function and render the various UI states accordingly.
- Cancellation on unmount / destroy.
- Optional automatic start on mount.
- Automatic restart on certain prop changes.
- Support both automatic start and manual start at the same time, e.g. to populate a form with existing data and submit it later.
- Control over when a certain state is rendered (e.g. persist old data while new data is loading).
- Server-side rendering and rehydration.
- Allow async functions to depend on eachother (e.g. one's result is used to construct/start another).
- Support stale-while-revalidate, like SWR.
🔌 User provided / plugin
- Allow debouncing / throttling / caching / retries.
- Automatic JSON (de)serialization.
Metadata
Metadata
Assignees
Labels
No labels