Function: createClientFactory()
Call Signature
createClientFactory<
T>(contract): (baseUrl,options?) =>InferClient<T>
Defined in: src/client.ts:134
Creates a factory function pre-configured with a contract.
Useful for wrapping a contract once and exposing a simple (baseUrl, options) => client function.
Type Parameters
| Type Parameter |
|---|
T extends Contract |
Parameters
| Parameter | Type | Description |
|---|---|---|
contract | T | The contract to bind. |
Returns
A factory that creates clients for the given contract.
(baseUrl, options?) => InferClient<T>
Example
ts
import { createClientFactory } from 'sorbus';
// Inferred from contract
const makeClient = createClientFactory(contract);
// Explicit return type (e.g. pre-computed Client interface)
const makeClient = createClientFactory<Client>(contract);
const dev = makeClient('http://localhost:3000');
const prod = makeClient('https://api.example.com');Call Signature
createClientFactory<
T>(contract): (baseUrl,options?) =>T
Defined in: src/client.ts:137
Creates a factory function pre-configured with a contract.
Useful for wrapping a contract once and exposing a simple (baseUrl, options) => client function.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
contract | Contract | The contract to bind. |
Returns
A factory that creates clients for the given contract.
(baseUrl, options?) => T
Example
ts
import { createClientFactory } from 'sorbus';
// Inferred from contract
const makeClient = createClientFactory(contract);
// Explicit return type (e.g. pre-computed Client interface)
const makeClient = createClientFactory<Client>(contract);
const dev = makeClient('http://localhost:3000');
const prod = makeClient('https://api.example.com');