UseCurrencyConverter
katanakit-js / useCurrencyConverter
Function: useCurrencyConverter()
Section titled “Function: 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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? |
CurrencyConverterServiceOptions |
Provider and cache TTL. ttlMs is applied through useSetTtlMs, so it also works on the shared instance. |
Returns
Section titled “Returns”The shared CurrencyConverterService (Singleton).
Example
Section titled “Example”import { useCurrencyConverter } from "katanakit-js";
const currency = useCurrencyConverter();const unsubscribe = currency.useSubscribe({ onRatesUpdate: (s) => render(s) });