function cachedClientFactory
cachedClientFactory<
Config,
Client,
>
(opts: { provider: LogCategory; missingMessage: string; getConfig: () => Config | null; isSameConfig: (
a: Config,
b: Config,
) => boolean
; create: (config: Config) => Client | Promise<Client>; createMessage?: (config: Config) => string; }
): { getClient: () => Promise<Client | null>; reset: () => void; }

Cache a provider API client keyed on its config. Reuses the cached client while the config is unchanged and recreates it when the config changes; returns null when the provider is unconfigured.

Type Parameters

Config
Client

Parameters

opts: { provider: LogCategory; missingMessage: string; getConfig: () => Config | null; isSameConfig: (
a: Config,
b: Config,
) => boolean
; create: (config: Config) => Client | Promise<Client>; createMessage?: (config: Config) => string; }

Return Type

{ getClient: () => Promise<Client | null>; reset: () => void; }

Usage

import { cachedClientFactory } from "doc.ts";