This package provides bundle factories for `redux-bundler`, specializing in the management of asynchronous data resources. It offers `createAsyncResourceBundle` for handling single remote resources and `createAsyncResourcesBundle` for managing collections of async resources, each with its own lifecycle, including loading, staleness, and expiration. Key features include configurable `staleAfter` and `expireAfter` durations to manage data freshness and automatic removal, a `dependencyKey` mechanism for conditional fetching and automatic cache invalidation based on upstream selector changes, and support for `doAdjust` actions to optimistically update resource state after mutations. The current stable version is 2.0.1. Releases appear to be ad-hoc, driven by new features or bug fixes, rather than a strict time-based cadence. It differentiates itself by providing a more robust and opinionated approach to async resource management within the `redux-bundler` ecosystem, extending beyond `redux-bundler`'s native capabilities.
npm install redux-bundler-async-resourcesVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to define an async resource bundle for fetching and managing a single list of hot car deals, integrating it with a React component using `redux-bundler-hook`.
Review usage of `createAsyncResourceBundle` and associated selectors/actions for any unexpected behavior or performance changes. Consult the changelog for details if available.
Carefully configure `staleAfter` for desired background refresh frequency and `expireAfter` for explicit cache invalidation. Set `Infinity` to disable either mechanism.
Ensure `dependencyKey` selectors return stable, memoized values. Avoid using selectors that return new object/array instances on every render unless explicit re-fetching is desired.
Always ensure compatible versions of `redux-bundler-async-resources` and `redux-bundler-async-resources-hooks`. Refer to the respective package release notes for compatibility guidance.
Ensure all necessary dependencies for `getPromise` are injected into the bundler's context via the `composeBundles` configuration.
Pass the necessary API client or service into `composeBundles` when initializing the store, e.g., `composeBundles(myBundle, { getShopApi: () => shopApiInstance })`.Update imports to use ES Modules syntax: `import { createAsyncResourceBundle } from 'redux-bundler-async-resources';`.Verify the `name` property passed to `createAsyncResourceBundle` exactly matches the base name used in selectors (e.g., 'hotCarDeals' for `selectHotCarDealsIsPendingForFetch`). Ensure the bundle is included in your `composeBundles` call.