Context.Reference<Map<string, Config.Config<unknown>>>The process-wide allowlist of declared-swappable env keys → their Config, held the way
Effect holds its own registries (Metric.MetricRegistry): a Context.Reference whose
cached default is the global — declare swappable anywhere, no wiring — while a
test or isolated program can substitute its own allowlist with
Effect.provideService(SwappableRegistry, new Map()).
export const const SwappableRegistry: Context.Reference<
Map<string, Config.Config<unknown>>
>
const SwappableRegistry: {
key: string;
Service: {
clear: () => void;
delete: (key: string) => boolean;
forEach: (callbackfn: (value: Config.Config<unknown>, key: string, map: Map<string, Config.Config<unknown>>) => void, thisArg?: any) => void;
get: (key: string) => Config.Config<unknown> | undefined;
has: (key: string) => boolean;
set: (key: string, value: Config.Config<unknown>) => Map<string, Config.Config<unknown>>;
size: number;
entries: () => MapIterator<[string, Config.Config<unknown>]>;
keys: () => MapIterator<string>;
values: () => MapIterator<Config.Config<unknown>>;
};
defaultValue: () => Shape;
of: (this: void, self: Map<string, Config.Config<unknown>>) => Map<string, Config.Config<unknown>>;
context: (self: Map<string, Config.Config<unknown>>) => Context.Context<never>;
use: (f: (service: Map<string, Config.Config<unknown>>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
useSync: (f: (service: Map<string, Config.Config<unknown>>) => A) => Effect.Effect<A, never, never>;
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
The process-wide allowlist of declared-swappable env keys → their Config, held the way
Effect holds its own registries (Metric.MetricRegistry): a Context.Reference whose
cached default is the global — declare
swappable
anywhere, no wiring — while a
test or isolated program can substitute its own allowlist with
Effect.provideService(SwappableRegistry, new Map()).
SwappableRegistry = import ContextContext.const Reference: <Map<string, Config.Config<unknown>>>(key: string, options: {
readonly defaultValue: () => Map<string, Config.Config<unknown>>;
}) => Context.Reference<Map<string, Config.Config<unknown>>>
Creates a context key with a default value.
When to use
Use when you need to define a context key with a lazily computed default
value.
Details
Context.Reference allows you to create a key that can hold a value. You
can provide a default value for the service, which will automatically be used
when the context is accessed, or override it with a custom implementation
when needed. The default value is computed lazily and cached on the
reference.
Example (Creating references with default values)
import { Context } from "effect"
// Create a reference with a default value
const LoggerRef = Context.Reference("Logger", {
defaultValue: () => ({ log: (msg: string) => console.log(msg) })
})
// The reference provides the default value when accessed from an empty context
const context = Context.empty()
const logger = Context.get(context, LoggerRef)
// You can also override the default value
const customContext = Context.make(LoggerRef, {
log: (msg: string) => `Custom: ${msg}`
})
const customLogger = Context.get(customContext, LoggerRef)
Reference<
interface Map<K, V>Map<string, import ConfigConfig.interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<unknown>>
>(const SwappableRegistryKey: "hyperlink-ts/DynamicConfig/SwappableRegistry"SwappableRegistryKey, { defaultValue: () => Map<
string,
Config.Config<unknown>
>
defaultValue: () => new var Map: MapConstructor
new () => Map<any, any> (+3 overloads)
Map() });