1.0.0 • Published 9 months ago
rdf-data-fetcher v1.0.0
RDF Data Fetcher
A flexible data fetching package for React components with SSR and CSR support.
Installation
npm install rdf-data-fetcherFeatures
- Support for both Server-Side Rendering (SSR) and Client-Side Rendering (CSR)
- Four types of fetching functions:
asyncLarge: For large async data fetching operationsasyncSmall: For small async data fetching operationssyncLarge: For large synchronous data processingsyncSmall: For small synchronous data operations
- Registry system for managing fetch functions
- TypeScript support
Usage
Basic Usage
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');Available Functions
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' });
Registry Usage
// Register a fetch function
fetcherRegistry.register(fetchFunction, 'uniqueName');
// Get a registered fetch function
const fetchFunction = fetcherRegistry.get('uniqueName');License
MIT
1.0.0
9 months ago