Quick Start
Core API Usage
Learn how to use qortex-core in any JavaScript environment.
Using qortex-core is simple. Register a fetcher, then fetch data anywhere.
1. Register a Fetcher
Define how to fetch your data:
1. Register a Fetcher
import { registerFetcher } from 'qortex-core';registerFetcher('users', async () => {const res = await fetch('/api/users');return res.json();});
2. Fetch Data
Fetch data anywhere in your app. It will be cached automatically.
2. Fetch Data
import { fetchQuery } from 'qortex-core';// Fetches and cachesconst users = await fetchQuery('users');// Subsequent calls return cached data instantlyconst cachedUsers = await fetchQuery('users');
3. Subscribe to Changes
Listen for data updates:
3. Subscribe to Changes
import { subscribeQuery } from 'qortex-core';const unsubscribe = subscribeQuery('users', (data) => {console.log('Users updated:', data);});