Skip to content

UseCurrencyConverter

katanakit-js / useCurrencyConverter

function useCurrencyConverter(options?): CurrencyConverterService;

Defined in: infrastructure/currency/currency.service.ts:36

Wires the shared CurrencyConverterService with the default rate source (Frankfurter) and returns it.

This is the composition point between the pure core service and the infrastructure that performs the network I/O: the core only knows the ICurrencyRateProvider port, so someone has to plug an implementation in. Calling this once is that “someone” — and it is idempotent, so calling it on every use is fine and a provider you injected yourself is never replaced.

Parameter Type Description
options? CurrencyConverterServiceOptions Provider and cache TTL. ttlMs is applied through useSetTtlMs, so it also works on the shared instance.

CurrencyConverterService

The shared CurrencyConverterService (Singleton).

import { useCurrencyConverter } from "katanakit-js";
const currency = useCurrencyConverter();
const unsubscribe = currency.useSubscribe({ onRatesUpdate: (s) => render(s) });