rdf-data-fetcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

RDF Data Fetcher

A flexible data fetching package for React components with SSR and CSR support.

Installation

npm install rdf-data-fetcher

Features

  • 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

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

  1. createAsyncLarge: For large async operations

    const asyncLarge = createAsyncLarge(fetchFunction, { config: 'server' | 'client' });
  2. createAsyncSmall: For small async operations

    const asyncSmall = createAsyncSmall(fetchFunction, { config: 'server' | 'client' });
  3. createSyncLarge: For large sync operations

    const syncLarge = createSyncLarge(fetchFunction, { config: 'server' | 'client' });
  4. createSyncSmall: For small sync operations

    const 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

Dependents (0)

Package Sidebar

Install

npm i rdf-data-fetcher

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

17.1 kB

Total Files

15

Last publish

Collaborators

  • yashrajsingh