A flexible data fetching package for React components with SSR and CSR support.
npm install rdf-data-fetcher
- Support for both Server-Side Rendering (SSR) and Client-Side Rendering (CSR)
- Four types of fetching functions:
-
asyncLarge
: For large async data fetching operations -
asyncSmall
: For small async data fetching operations -
syncLarge
: For large synchronous data processing -
syncSmall
: For small synchronous data operations
-
- Registry system for managing fetch functions
- TypeScript support
import { createAsyncLarge, fetcherRegistry } from 'rdf-data-fetcher';
// Create a fetch function
const fetchUsers = async () => {
const response = await fetch('https://api.example.com/users');
return response.json();
};
// Create a configured fetch function
const asyncUsers = createAsyncLarge(fetchUsers, { config: 'server' });
// Register the fetch function
fetcherRegistry.register(asyncUsers, 'users');
-
createAsyncLarge
: For large async operationsconst asyncLarge = createAsyncLarge(fetchFunction, { config: 'server' | 'client' });
-
createAsyncSmall
: For small async operationsconst asyncSmall = createAsyncSmall(fetchFunction, { config: 'server' | 'client' });
-
createSyncLarge
: For large sync operationsconst syncLarge = createSyncLarge(fetchFunction, { config: 'server' | 'client' });
-
createSyncSmall
: For small sync operationsconst syncSmall = createSyncSmall(fetchFunction, { config: 'server' | 'client' });
// Register a fetch function
fetcherRegistry.register(fetchFunction, 'uniqueName');
// Get a registered fetch function
const fetchFunction = fetcherRegistry.get('uniqueName');
MIT